From fafd0972baa02a31a4245f40035ce9824b99f7cc Mon Sep 17 00:00:00 2001 From: Lars Kiesow Date: Fri, 7 Jun 2024 16:33:47 +0200 Subject: [PATCH] Use moment.js for getting an ISO date string Moment allows you to get a fate string based on local time which is exactly what we need. --- src/utils/dateUtils.ts | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/src/utils/dateUtils.ts b/src/utils/dateUtils.ts index 5976d129aa..cbf6ef693a 100644 --- a/src/utils/dateUtils.ts +++ b/src/utils/dateUtils.ts @@ -7,9 +7,7 @@ import { makeTwoDigits } from "./utils"; // Get the ISO date string based on local time const getISODateString = (date: Date) => { - const offsetHours = Math.trunc(date.getTimezoneOffset() / 60) - const offsetMinutes = date.getTimezoneOffset() % 60 - return new Date(date.setHours(-offsetHours, -offsetMinutes, 0)).toISOString().substring(0, 10); + return moment(date).format('YYYY-MM-DD'); } // check if date can be parsed