Skip to content

Commit

Permalink
bug fix - compare start and end date in ny timezone
Browse files Browse the repository at this point in the history
  • Loading branch information
dougchestnut committed Aug 4, 2023
1 parent 300284a commit e86d039
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 7 deletions.
3 changes: 2 additions & 1 deletion packages/bento-box/demo/EventSection.html
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,10 @@
<body>
<div>
<script type="module" src="../dist/src/events-section.js"></script>
<!--
<h2>Events-Section example</h2>
<events-section no-style no-shadow-dom limit="5"></events-section>

-->
<h2>Events-Section limited title example</h2>
<events-section no-style no-shadow-dom max-title-length="5" limit="5"></events-section>
</div>
Expand Down
12 changes: 6 additions & 6 deletions packages/bento-box/src/EventsSection.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down

0 comments on commit e86d039

Please sign in to comment.