-
Notifications
You must be signed in to change notification settings - Fork 0
Description
Problem Statement:
In reviewing the acceptance of date and time values, we are evaluating whether to allow input formats that do not use zero-padding (e.g., "3/5/2025" instead of "03/05/2025"). A key consideration is whether such inputs are reliably parsed using the strptime standard, which is commonly used in downstream systems for date/time interpretation.
General Support Across Systems:
Based on a preliminary review, while the POSIX specification for strptime defines format codes like %m, %d, and %H as matching zero-padded numeric values, it seems most real-world implementations—including GNU libc, BSD libc (macOS), and Python—accept both zero-padded and non-zero-padded input. This means that values like "3" for %m or "7" for %H are typically parsed correctly, even if not explicitly guaranteed by the standard.
Typical Behavior:
This suggests:
%m,%d,%H,%M,%S,%Y, and%yall generally accept single-digit input values.- Parsers are forgiving and often consume as many digits as make sense, regardless of padding.
Possible Edge Case and Limitation:
- Embedded systems or constrained environments may use minimal libc implementations that follow the standard more strictly.
Recommendation Considerations:
- If maximum interoperability and strict schema validation are priorities, requiring zero-padded input ensures full compliance and predictability.
- If user flexibility and leniency are more important, allowing non-zero-padded input is unlikely to cause practical issues on mainstream systems, but should be tested.