Showing 'tomorrow' and future dated stories correctly on the web.

This commit is contained in:
Samuel Clay 2017-06-07 17:51:27 -07:00
parent 1f0041cff2
commit 991a9a7d72

View file

@ -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 {