chrono icon indicating copy to clipboard operation
chrono copied to clipboard

Parsing preparations

Open pitdicker opened this issue 1 year ago • 2 comments

These issues came up when trying to convert our parsing code to the new error types (only 750 errors to go... :laughing:).

I would like to restrict the visibility of ParseError to the format module on 0.5, and make all parsing go through format::parsed. That means the FromStr implementations of DateTime<FixedOffset> and FixedOffset should use the standard parsing methods instead of reaching directly for the functions in format::{parse, scan}.

In timezone_offset I simplified digit parsing a bit because it did not have quite the places to hook up new error values as I wanted. It remains a pretty broken parser though.

Further I noticed a 0i64.checked_sub(v).ok_or(OUT_OF_RANGE) line. Subtracting a positive i64 from 0 can never fail. Then I noticed we don't support parsing negative timestamps at all! That is fixed in the last commit. Parsing i64::MIN was a little tricky.

pitdicker avatar Mar 02 '24 07:03 pitdicker

Codecov Report

Attention: Patch coverage is 98.07692% with 1 lines in your changes are missing coverage. Please review.

Project coverage is 91.83%. Comparing base (391187f) to head (3b7fa22).

Files Patch % Lines
src/format/scan.rs 96.77% 1 Missing :warning:
Additional details and impacted files
@@           Coverage Diff           @@
##             main    #1479   +/-   ##
=======================================
  Coverage   91.82%   91.83%           
=======================================
  Files          37       37           
  Lines       18173    18166    -7     
=======================================
- Hits        16687    16682    -5     
+ Misses       1486     1484    -2     

:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.

codecov[bot] avatar Mar 02 '24 07:03 codecov[bot]

Added another commit to remove some duplicated length checks. They where just before scan::nanosecond_fixed, which uses scan::number that does the same checks.

pitdicker avatar Mar 05 '24 14:03 pitdicker