From e86d03987c5a8d84b84042c76692493dc1afc66e Mon Sep 17 00:00:00 2001 From: Doug Chestnut Date: Fri, 4 Aug 2023 13:29:02 -0400 Subject: [PATCH] bug fix - compare start and end date in ny timezone --- packages/bento-box/demo/EventSection.html | 3 ++- packages/bento-box/src/EventsSection.ts | 12 ++++++------ 2 files changed, 8 insertions(+), 7 deletions(-) diff --git a/packages/bento-box/demo/EventSection.html b/packages/bento-box/demo/EventSection.html index f019f6ada..94ff9ee99 100644 --- a/packages/bento-box/demo/EventSection.html +++ b/packages/bento-box/demo/EventSection.html @@ -11,9 +11,10 @@
+

Events-Section limited title example

diff --git a/packages/bento-box/src/EventsSection.ts b/packages/bento-box/src/EventsSection.ts index b22c54411..ef73829de 100644 --- a/packages/bento-box/src/EventsSection.ts +++ b/packages/bento-box/src/EventsSection.ts @@ -40,14 +40,14 @@ export class EventsSection extends BentoSection { ` } - static isSameDay(date1: Date, date2: Date): boolean { - return ( - date1.getFullYear() === date2.getFullYear() && - date1.getMonth() === date2.getMonth() && - date1.getDate() === date2.getDate() - ); + static isSameDay(date1: Date, date2: Date, timeZone: string = 'America/New_York'): boolean { + function toDateString(date: Date) { + return date.toLocaleDateString('en-US', {timeZone}); + } + return toDateString(date1) === toDateString(date2); } + static dateRange(_start: number|undefined, _end: number|undefined){ const start = _start? new Date(_start): new Date(); const end = _end? new Date(_end): new Date();