Skip to content

Commit 51382e6

Browse files
authored
fix: dateToUnix to preserve the date #434
trunc the ms instead of round to avoid edge cases where the date would be changed example: Math.round((new Date('2024-12-10T23:59:59.999Z')).getTime() / 1000) vs Math.trunc((new Date('2024-12-10T23:59:59.999Z')).getTime() / 1000)
1 parent f42771c commit 51382e6

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

src/Date/dateUtils.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ export function showWeekDay(
1212
}
1313

1414
export function dateToUnix(d: Date): number {
15-
return Math.round(d.getTime() / 1000)
15+
return Math.trunc(d.getTime() / 1000)
1616
}
1717

1818
export function addMonths(date: Date, count: number) {

0 commit comments

Comments
 (0)