-
Notifications
You must be signed in to change notification settings - Fork 581
Description
The documentation states that %S represents "Second number (00–60), zero-padded to 2 digits."
Given this, I would expect the following behavior when parsing timestamps with NaiveTime::parse_from_str
:
✅ Valid: "010233" with "%H%M%S" parses successfully as 01:02:33.
❌ Too Long: "0102334" with "%H%M%S" fails with an error (correct).
❌ Too Short: "01023" with "%H%M%S" should fail — but instead, it parses as 01:02:03.
This seems inconsistent. Even more confusingly:
If we remove the first zero (e.g., "10233"), it parses as 10:23:03 — a completely different time.
Expected Behavior
For the format "%H%M%S", any input length other than 6 digits should result in an error.
Suggested Fix
Either:
Strict parsing: Enforce exact digit matching (6 digits for %H%M%S).
Document the behavior: Explicitly clarify that trailing digits may be ignored or that partial parsing is allowed.
Currently, the behavior is unintuitive and could lead to subtle bugs.