From 991a9a7d725f3a1251a063cf95950b44b51b7d56 Mon Sep 17 00:00:00 2001 From: Samuel Clay Date: Wed, 7 Jun 2017 17:51:27 -0700 Subject: [PATCH] Showing 'tomorrow' and future dated stories correctly on the web. --- media/js/newsblur/models/stories.js | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/media/js/newsblur/models/stories.js b/media/js/newsblur/models/stories.js index a0eddc005..7e80d7fa9 100644 --- a/media/js/newsblur/models/stories.js +++ b/media/js/newsblur/models/stories.js @@ -69,14 +69,26 @@ NEWSBLUR.Models.Story = Backbone.Model.extend({ midnight.setSeconds(0); return midnight; }; + var midnight_tomorrow = function(midnight, days) { + if (!days) days = 1; + return new Date(midnight + days*60*60*24*1000); + }; var midnight_yesterday = function(midnight) { - return new Date(midnight - 60*60*24*1000); + return midnight_tomorrow(midnight, -1); }; var midnight = midnight_today(); var time = date.format(dateformat == "24" ? "H:i" : "g:ia"); if (date > midnight) { - return time; + if (date > midnight_tomorrow(midnight)) { + if (date < midnight_tomorrow(midnight, 2)) { + return "Tomorrow, " + time; + } else { + return date.format("d M Y, ") + time; + } + } else { + return time; + } } else if (date > midnight_yesterday(midnight)) { return "Yesterday, " + time; } else {