Skip to content

Commit 2e2d0fc

Browse files
committed
Add support for RFC9557 6-digit years preceded by + or -
1 parent 298a231 commit 2e2d0fc

File tree

2 files changed

+8
-2
lines changed

2 files changed

+8
-2
lines changed

parse.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@ export class IsoDateParts {
55
minutes: 0,
66
};
77

8-
static FULL_DATE_REGEX = /^(\d{4})-?([01]\d)-?([0-3]\d)$/;
9-
static DATETIME_REGEX = /^(\d{4})-?([01]\d)-?([0-3]\d)T([0-2]\d(?:[\.\,]\d+)?)(?::?([0-5]\d(?:[\.\,]\d+)?)(?::?([0-5]\d))?(?:[\.\,](\d+))?)?(Z|[+-][0-2]\d(?::?[0-5]\d)?)?$/;
8+
static FULL_DATE_REGEX = /^([+-]\d{6}|\d{4})-?([01]\d)-?([0-3]\d)$/;
9+
static DATETIME_REGEX = /^([+-]\d{6}|\d{4})-?([01]\d)-?([0-3]\d)T([0-2]\d(?:[\.\,]\d+)?)(?::?([0-5]\d(?:[\.\,]\d+)?)(?::?([0-5]\d))?(?:[\.\,](\d+))?)?(Z|[+-][0-2]\d(?::?[0-5]\d)?)?$/;
1010
static TIMEZONE_REGEX = /^([+-]\d{2})(?::?(\d{2}))?$/;
1111
static IS_FRACTIONAL_REGEX = /^\d+[\.\,]\d+$/;
1212

test/utils.js

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,12 @@ export const VALID_TEST_CASES = `
7575
2016-05-25T09:24:15+0600
7676
2016-05-25T09:24:15-06
7777
2016-05-25T09:24:15-0600
78+
79+
// 6 digit years
80+
+002000-01-01
81+
-002000-01-01
82+
+0020000101
83+
-0020000101
7884
`
7985

8086
// Expected to fail

0 commit comments

Comments
 (0)