From fbce32f34154118a1d8fc6dbe76b9b3d94edc5a7 Mon Sep 17 00:00:00 2001 From: Liam DeBeasi Date: Wed, 13 Apr 2022 16:29:54 +0000 Subject: [PATCH 1/2] fix(datetime): account for 30 and 45 minute timezones when getting current date --- core/src/components/datetime/utils/data.ts | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/core/src/components/datetime/utils/data.ts b/core/src/components/datetime/utils/data.ts index f3e860f4f92..bf2d9d22eb9 100644 --- a/core/src/components/datetime/utils/data.ts +++ b/core/src/components/datetime/utils/data.ts @@ -27,7 +27,24 @@ export const getToday = () => { * there was a net change of zero hours from the * local date. */ - date.setHours(date.getHours() - tzOffset / 60); + const adjustedHours = date.getHours() - tzOffset / 60; + + /** + * Some timezones have include minute adjustments + * such as 30 or 45 minutes. + * Example: India Standard Time + * Timezone offset: -330 = -5.5 hours. + * + * As a result, we need to make sure we also + * increment the minutes as well. + * List of timezones with 30 and 45 minute timezones: + * https://www.timeanddate.com/time/time-zones-interesting.html + */ + const minutesRemainder = adjustedHours % 1; + const adjustedMinutes = date.getMinutes() + minutesRemainder * 60; + date.setHours(adjustedHours); + date.setMinutes(adjustedMinutes); + return date.toISOString(); }; From 20be71df727a15ecb4e315bb2b6d15b94536f82a Mon Sep 17 00:00:00 2001 From: Liam DeBeasi Date: Wed, 13 Apr 2022 12:49:53 -0400 Subject: [PATCH 2/2] Update core/src/components/datetime/utils/data.ts Co-authored-by: Sean Perkins --- core/src/components/datetime/utils/data.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/core/src/components/datetime/utils/data.ts b/core/src/components/datetime/utils/data.ts index bf2d9d22eb9..853cc449628 100644 --- a/core/src/components/datetime/utils/data.ts +++ b/core/src/components/datetime/utils/data.ts @@ -30,7 +30,7 @@ export const getToday = () => { const adjustedHours = date.getHours() - tzOffset / 60; /** - * Some timezones have include minute adjustments + * Some timezones include minute adjustments * such as 30 or 45 minutes. * Example: India Standard Time * Timezone offset: -330 = -5.5 hours.