Skip to content

Commit

Permalink
fix: dateToUnix to preserve the date #434
Browse files Browse the repository at this point in the history
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)
  • Loading branch information
DerBasler authored Dec 11, 2024
1 parent f42771c commit 51382e6
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion src/Date/dateUtils.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ export function showWeekDay(
}

export function dateToUnix(d: Date): number {
return Math.round(d.getTime() / 1000)
return Math.trunc(d.getTime() / 1000)
}

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

0 comments on commit 51382e6

Please sign in to comment.