Skip to content

Commit 7555a00

Browse files
Copilotdrewsonne
andcommitted
Improve ISO 8601 regex pattern comment clarity
- Clarify that regex requires 4 or more digits for year component - Add examples of valid ISO 8601 dates in comment - No functional changes Co-authored-by: drewsonne <[email protected]>
1 parent 8c520ea commit 7555a00

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

src/factory/gregorian.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,8 @@ export default class GregorianFactory {
3232
let cleanedGregorian = gregorian.replace(/\*/g, '').trim();
3333

3434
// Detect format: ISO 8601 (YYYY-MM-DD) vs DD/MM/YYYY
35-
// ISO 8601 pattern: optional minus, 4+ digits, dash, 2 digits, dash, 2 digits
35+
// ISO 8601 pattern: optional minus, 4 or more digits for year, dash, 2 digits for month, dash, 2 digits for day
36+
// Examples: 2024-01-01, 0001-12-31, -0332-03-05, 12345-06-15
3637
const iso8601Pattern = /^(-?\d{4,})-(\d{2})-(\d{2})$/;
3738
const iso8601Match = cleanedGregorian.match(iso8601Pattern);
3839

0 commit comments

Comments
 (0)