Conversation
The ISO 8601 timezone sub-pattern used a capturing group `(:?\d\d)` where a non-capturing group `(?:\d\d)` was intended. The transposed `:?`/`?:` let an extra colon slip through, so parse_date() accepted malformed offsets like `-01::00` and returned them verbatim as the timezone. Use a non-capturing group so the colon separator is matched only by the outer `:?`. Well-formed offsets (-01:00, -0100, -01) are unaffected. Closes #7 Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## master #31 +/- ##
=======================================
Coverage 89.70% 89.70%
=======================================
Files 1 1
Lines 68 68
Branches 29 29
=======================================
Hits 61 61
Misses 1 1
Partials 6 6 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #7
Problem
parse_dateaccepted a malformed ISO 8601 timezone such as1996-02-29 12:00:00 -01::00and returned the bad string-01::00verbatim as the timezone field.Cause
The timezone sub-pattern used a capturing group
(:?[0-9][0-9])where a non-capturing group(?:[0-9][0-9])was intended — the:and?were transposed. The stray inner:?let a second colon be consumed, so a doubled colon slipped through.Fix
Use a non-capturing group
(?:[0-9][0-9])so the colon separator is matched only by the outer:?. Well-formed offsets (-01:00,-0100,-01,Z) are unaffected.Testing
parse_date("...-01::00")returns an empty list; verified it fails on the pre-fix code and passes with the fix.-01:00,-0100, and-01still parse with the timezone returned intact.