From 53b9c17decda30c700220ac02872c930995c1830 Mon Sep 17 00:00:00 2001 From: zoobestik Date: Tue, 3 Oct 2023 14:54:24 +0200 Subject: [PATCH] fix(KTL-1151): community events: event is on the past tab despite it is today --- blocks/community/event-list/community-event.ts | 2 +- static/js/util/date.js | 5 ++++- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/blocks/community/event-list/community-event.ts b/blocks/community/event-list/community-event.ts index d2091cd0b1a..f6cd7ee48e7 100644 --- a/blocks/community/event-list/community-event.ts +++ b/blocks/community/event-list/community-event.ts @@ -31,7 +31,7 @@ export class CommunityEvent { this.lang = data.lang || DEFAULT_LANG; this.content = data.content; this.startDate = new Date(data.startDate + 'T00:00:00'); - this.endDate = new Date(data.endDate + 'T00:00:00'); + this.endDate = new Date(data.endDate + 'T23:59:59'); this.formattedDate = formatDate(this.startDate, this.endDate); } diff --git a/static/js/util/date.js b/static/js/util/date.js index 033fa0f89a8..fa89abb7d07 100644 --- a/static/js/util/date.js +++ b/static/js/util/date.js @@ -1,7 +1,10 @@ export function formatDate(startDate, endDate) { let formatted = ''; let year, month, day; - const isRange = startDate.getTime() !== endDate.getTime(); + const isRange = (startDate.getDate() !== endDate.getDate() || + startDate.getMonth() !== endDate.getMonth() || + startDate.getFullYear() !== endDate.getFullYear() + ); const nowYear = new Date().getFullYear(); const months = [