Skip to content

Commit

Permalink
Allow parsing month of October (#1489)
Browse files Browse the repository at this point in the history
  • Loading branch information
duranb authored Oct 3, 2024
1 parent 2494838 commit 90b9f25
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 1 deletion.
11 changes: 11 additions & 0 deletions src/utilities/time.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -282,6 +282,17 @@ test('parseDoyOrYmdTime', () => {
year: 2022,
});

expect(parseDoyOrYmdTime('2022-10-2T00:00:00')).toEqual({
day: 2,
hour: 0,
min: 0,
month: 10,
ms: 0,
sec: 0,
time: '00:00:00',
year: 2022,
});

expect(parseDoyOrYmdTime('012T03:01:30.920')).toEqual({
days: 12,
hours: 3,
Expand Down
2 changes: 1 addition & 1 deletion src/utilities/time.ts
Original file line number Diff line number Diff line change
Expand Up @@ -773,7 +773,7 @@ export function parseDoyOrYmdTime(
): null | ParsedDoyString | ParsedYmdString | ParsedDurationString {
const matches = (dateString ?? '').match(
new RegExp(
`^(?<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}})?)?)?)?$`,
`^(?<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}})?)?)?)?$`,
'i',
),
);
Expand Down

0 comments on commit 90b9f25

Please sign in to comment.