From 09ddfe8be83fe8644bce71ac9230a0bd061326f3 Mon Sep 17 00:00:00 2001 From: Tom Hacohen Date: Thu, 14 Feb 2019 20:15:48 +0000 Subject: [PATCH] Event: fix date calculation to account for exact same dates. --- src/components/Event.tsx | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/components/Event.tsx b/src/components/Event.tsx index afb643d..5ea9296 100644 --- a/src/components/Event.tsx +++ b/src/components/Event.tsx @@ -24,9 +24,13 @@ function formatDateRange(start: ICAL.Time, end: ICAL.Time) { strStart = mStart.format(allDayFormat); strEnd = mEnd.clone().subtract(1, 'day').format(allDayFormat); } - } else if ((mStart.day === mEnd.day) && (mEnd.diff(mStart, 'days', true) < 1)) { + } else if (mStart.isSame(mEnd, 'day')) { strStart = mStart.format(fullFormat); strEnd = mEnd.format('LT'); + + if (mStart.isSame(mEnd)) { + return strStart; + } } else { strStart = mStart.format(fullFormat); strEnd = mEnd.format(fullFormat);