From 6328fc6f9013cbdb08d9c19ac2a2318652a4e8a4 Mon Sep 17 00:00:00 2001 From: Gabe Kangas Date: Mon, 19 Jul 2021 18:51:10 -0700 Subject: [PATCH] Fix date comparison for showing last stream date. Closes https://github.com/owncast/owncast/issues/1223 --- webroot/js/utils/helpers.js | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/webroot/js/utils/helpers.js b/webroot/js/utils/helpers.js index c9b0ccc69..f9fc9c1e5 100644 --- a/webroot/js/utils/helpers.js +++ b/webroot/js/utils/helpers.js @@ -168,15 +168,17 @@ export function makeLastOnlineString(timestamp) { } let string = ''; const time = new Date(timestamp); - let diffInDays = getDiffInDaysFromNow(time); - if (diffInDays > 1) { - string = time.toLocaleDateString(); - } else { + const comparisonDate = new Date(time).setHours(0,0,0,0); + + if(comparisonDate == new Date().setHours(0,0,0,0)) { const atTime = time.toLocaleTimeString([], { hour: '2-digit', minute: '2-digit', }); string = `Today ${atTime}`; + } else { + string = time.toLocaleDateString(); } + return `Last live: ${string}`; }