chrono icon indicating copy to clipboard operation
chrono copied to clipboard

Flexible offset parsing [2/3]

Open pitdicker opened this issue 2 years ago • 2 comments
trafficstars

The first commit is shared with https://github.com/chronotope/chrono/pull/1082. Then a couple of commits do some cleanup and add a new offset parser. All the test keep passing, except some of those for #z. The difference is in the error causes, which have improved a bit.

Next are commits to make %:z, %::z and %:::z work as documented:

  • %:z should require a colon (this is what makes it different from %z).
  • %::z should also be able to parse, and even require, seconds.
  • %:::z should only accept hours.

Finally the FromStr implementation of DateTime<FixedOffset> now accepts optional seconds in the offset, so that it can parse the Debug format of DateTime.


TODO: I still need to figure out some way to test all the code paths of the new offset parser.

pitdicker avatar May 24 '23 19:05 pitdicker

I did not realize %::z and %:::z are fairly recent additions, added in https://github.com/chronotope/chrono/pull/759. Looking at that PR I understand they never properly added to the parser. That seems like an extra argument to fix them.

I'll keep this PR as a draft for a little longer. https://github.com/chronotope/chrono/pull/1145 has the proper fix for some changes I had to make here to RFC 3339 parsing code, and it is better if that is merged first.

pitdicker avatar Jun 23 '23 10:06 pitdicker

Codecov Report

Merging #1083 (7964d8f) into 0.4.x (00d389e) will increase coverage by 0.24%. Report is 6 commits behind head on 0.4.x. The diff coverage is 100.00%.

@@            Coverage Diff             @@
##            0.4.x    #1083      +/-   ##
==========================================
+ Coverage   86.10%   86.35%   +0.24%     
==========================================
  Files          37       37              
  Lines       13522    13776     +254     
==========================================
+ Hits        11643    11896     +253     
- Misses       1879     1880       +1     
Files Changed Coverage Δ
src/format/mod.rs 75.36% <ø> (ø)
src/datetime/tests.rs 96.56% <100.00%> (+0.02%) :arrow_up:
src/format/parse.rs 97.26% <100.00%> (+0.03%) :arrow_up:
src/format/scan.rs 99.38% <100.00%> (+0.12%) :arrow_up:
src/offset/fixed.rs 78.19% <100.00%> (+1.03%) :arrow_up:

:mega: We’re building smart automated test selection to slash your CI/CD build times. Learn more

codecov[bot] avatar Aug 11 '23 11:08 codecov[bot]