From 51382e6eea6973338e0dee0583b69a2f46a9fb99 Mon Sep 17 00:00:00 2001 From: DerBasler <45329909+DerBasler@users.noreply.github.com> Date: Wed, 11 Dec 2024 07:49:31 +0100 Subject: [PATCH] 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) --- src/Date/dateUtils.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Date/dateUtils.tsx b/src/Date/dateUtils.tsx index 34e0dc7..5356889 100644 --- a/src/Date/dateUtils.tsx +++ b/src/Date/dateUtils.tsx @@ -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) {