From 4764761c898dd65bcdf2af21d2cc582fad7ee01d Mon Sep 17 00:00:00 2001 From: Jens Spanier Date: Tue, 8 Aug 2023 13:18:18 +0200 Subject: [PATCH] Use `toISOString` instead of manual build --- src/utils.ts | 25 +------------------------ 1 file changed, 1 insertion(+), 24 deletions(-) diff --git a/src/utils.ts b/src/utils.ts index 2ce999f..578c483 100644 --- a/src/utils.ts +++ b/src/utils.ts @@ -36,30 +36,7 @@ function dateToW3CString(date: Date) { return undefined; } - const paddedMonth = padMeTwo(date.getMonth() + 1); - const paddedDay = padMeTwo(date.getDate()); - const paddedHour = padMeTwo(date.getHours()); - const paddedMinutes = padMeTwo(date.getMinutes()); - const paddedSeconds = padMeTwo(date.getSeconds()); - - /** - * Date.prototype.getTimezoneOffset returns the timezone UTC offset in - * minutes of the local machine. - * - * That value should then be used to calculate the effective timezone as - * string, but still that would be related to the machine and not to the - * specified date. - * - * For this reason we are completing date with "Z" TimeZoneDesignator (TZD) - * to say it to use local timezone. - * - * In the future we might think to integrate another parameter to represent - * a custom timezone. - * - * @see https://www.w3.org/TR/NOTE-datetime - */ - - return `${date.getFullYear()}-${paddedMonth}-${paddedDay}T${paddedHour}:${paddedMinutes}:${paddedSeconds}Z`; + return date.toISOString(); } function padMeTwo(original: string | number) {