Skip to content

Conversation

@chris-leach
Copy link
Contributor

When parsing, the "fixed-length decimal fraction" specifiers (%.3f, %.6f, %.9f) are currently treated identically to the variable-length specifier (%.f).

This causes issues when the fractional part is immediately followed by more digits signifying something completely different (you might think this bizarre, and I would agree, but I've seen upsetting things in vendor-specific log formats).

This PR changes the parser for those specifiers to consume only the exact number of digits specified, returning TooShort if there aren't enough. Test cases added for all three.

Fixes #1592.

@codecov
Copy link

codecov bot commented Jun 3, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 90.60%. Comparing base (3b4af71) to head (b6defb0).
Report is 1 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #1705      +/-   ##
==========================================
+ Coverage   90.59%   90.60%   +0.01%     
==========================================
  Files          38       38              
  Lines       16028    16058      +30     
==========================================
+ Hits        14520    14550      +30     
  Misses       1508     1508              

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Copy link
Member

@djc djc left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks!

@djc djc merged commit 2e1cd2f into chronotope:main Jun 3, 2025
35 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Err(ParseError(TooShort)) when parsing datetime with trailing 0

2 participants