Skip to content

Commit

Permalink
another fix for UTC import parsing
Browse files Browse the repository at this point in the history
  • Loading branch information
duranb committed Jul 24, 2024
1 parent 4888b00 commit 58c494b
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 3 deletions.
4 changes: 2 additions & 2 deletions src/routes/plans/+page.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -495,12 +495,12 @@
planTags = [...importedPlanTags.existingTags, ...newTags];
// remove the `+00:00` timezone before parsing
const startTime = `${convertDoyToYmd(planJSON.start_time.replace(/\+00:00/, ''))}Z`;
const startTime = `${convertDoyToYmd(planJSON.start_time.replace(/\+00:00/, ''))}`;
await startTimeField.validateAndSet(getDoyTime(new Date(startTime), true));
if (isDeprecatedPlanTransfer(planJSON)) {
await endTimeField.validateAndSet(
getDoyTime(new Date(`${convertDoyToYmd(planJSON.end_time.replace(/\+00:00/, ''))}Z`), true),
getDoyTime(new Date(`${convertDoyToYmd(planJSON.end_time.replace(/\+00:00/, ''))}`), true),
);
} else {
const { duration } = planJSON;
Expand Down
1 change: 1 addition & 0 deletions src/utilities/time.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -202,6 +202,7 @@ test('convertDoyToYmd', () => {
expect(convertDoyToYmd('2023-001T00:00:00', false)).toEqual('2023-01-01T00:00:00Z');
expect(convertDoyToYmd('2023-032T00:00:00', false)).toEqual('2023-02-01T00:00:00Z');
expect(convertDoyToYmd('2023-048T10:32:44.123', true)).toEqual('2023-02-17T10:32:44.123Z');
expect(convertDoyToYmd('2023-04-10T10:32:44.123', true)).toEqual('2023-04-10T10:32:44.123Z');
});

test('getDaysInMonth', () => {
Expand Down
2 changes: 1 addition & 1 deletion src/utilities/time.ts
Original file line number Diff line number Diff line change
Expand Up @@ -383,7 +383,7 @@ export function convertDoyToYmd(doyString: string, includeMsecs = true): string
return `${ymdString.replace(/(\.\d+)/, '')}Z`;
} else {
// doyString is already in ymd format
return doyString;
return `${doyString}Z`;
}
}

Expand Down

0 comments on commit 58c494b

Please sign in to comment.