Skip to content

Commit 703befb

Browse files
authored
Using UTC year/month/day in data-loader
1 parent 86abb24 commit 703befb

1 file changed

Lines changed: 6 additions & 6 deletions

File tree

‎src/data-loader.ts‎

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -427,9 +427,9 @@ function extractUniqueModels<T>(
427427
*/
428428
export function formatDate(dateStr: string): string {
429429
const date = new Date(dateStr);
430-
const year = date.getFullYear();
431-
const month = String(date.getMonth() + 1).padStart(2, '0');
432-
const day = String(date.getDate()).padStart(2, '0');
430+
const year = date.getUTCFullYear();
431+
const month = String(date.getUTCMonth() + 1).padStart(2, '0');
432+
const day = String(date.getUTCDate()).padStart(2, '0');
433433
return `${year}-${month}-${day}`;
434434
}
435435

@@ -440,9 +440,9 @@ export function formatDate(dateStr: string): string {
440440
*/
441441
export function formatDateCompact(dateStr: string): string {
442442
const date = new Date(dateStr);
443-
const year = date.getFullYear();
444-
const month = String(date.getMonth() + 1).padStart(2, '0');
445-
const day = String(date.getDate()).padStart(2, '0');
443+
const year = date.getUTCFullYear();
444+
const month = String(date.getUTCMonth() + 1).padStart(2, '0');
445+
const day = String(date.getUTCDate()).padStart(2, '0');
446446
return `${year}\n${month}-${day}`;
447447
}
448448

0 commit comments

Comments
 (0)