Skip to content

Commit 1f5e01a

Browse files
duranbJosephVolosin
authored andcommitted
Allow parsing month of October (#1489)
1 parent 64350dd commit 1f5e01a

File tree

2 files changed

+12
-1
lines changed

2 files changed

+12
-1
lines changed

src/utilities/time.test.ts

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -282,6 +282,17 @@ test('parseDoyOrYmdTime', () => {
282282
year: 2022,
283283
});
284284

285+
expect(parseDoyOrYmdTime('2022-10-2T00:00:00')).toEqual({
286+
day: 2,
287+
hour: 0,
288+
min: 0,
289+
month: 10,
290+
ms: 0,
291+
sec: 0,
292+
time: '00:00:00',
293+
year: 2022,
294+
});
295+
285296
expect(parseDoyOrYmdTime('012T03:01:30.920')).toEqual({
286297
days: 12,
287298
hours: 3,

src/utilities/time.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -773,7 +773,7 @@ export function parseDoyOrYmdTime(
773773
): null | ParsedDoyString | ParsedYmdString | ParsedDurationString {
774774
const matches = (dateString ?? '').match(
775775
new RegExp(
776-
`^(?<year>\\d{4})-(?:(?<month>(?:[0]?[0-9])|(?:[1][1-2]))-(?<day>(?:[0-2]?[0-9])|(?:[3][0-1]))|(?<doy>\\d{1,3}))(?:T(?<time>(?<hour>[0-9]|[0-2][0-9])(?::(?<min>[0-9]|(?:[0-5][0-9])))?(?::(?<sec>[0-9]|(?:[0-5][0-9]))(?<dec>\\.\\d{1,${numDecimals}})?)?)?)?$`,
776+
`^(?<year>\\d{4})-(?:(?<month>(?:[0]?[0-9])|(?:[1][0-2]))-(?<day>(?:[0-2]?[0-9])|(?:[3][0-1]))|(?<doy>\\d{1,3}))(?:T(?<time>(?<hour>[0-9]|[0-2][0-9])(?::(?<min>[0-9]|(?:[0-5][0-9])))?(?::(?<sec>[0-9]|(?:[0-5][0-9]))(?<dec>\\.\\d{1,${numDecimals}})?)?)?)?$`,
777777
'i',
778778
),
779779
);

0 commit comments

Comments
 (0)