mirror of
https://github.com/zulip/zulip.git
synced 2025-11-20 14:38:46 +00:00
uploads: Only display year uploaded if previous year.
Modified timerender.js absolute_time() to include the year in the returned string when the supplied timestamp is in an older year. This included adding an optional second argument to specify the current date to facilitate unit tests. Fixes #5737.
This commit is contained in:
committed by
Tim Abbott
parent
f7d1abaa25
commit
159064ccaa
@@ -235,11 +235,20 @@ exports.absolute_time = (function () {
|
||||
return str;
|
||||
};
|
||||
|
||||
return function (timestamp) {
|
||||
return function (timestamp, today) {
|
||||
if (typeof today === 'undefined') {
|
||||
today = new Date();
|
||||
}
|
||||
var date = new Date(timestamp);
|
||||
var is_older_year = (today.getFullYear() - date.getFullYear()) > 0;
|
||||
var H_24 = page_params.twenty_four_hour_time;
|
||||
|
||||
return MONTHS[date.getMonth()] + " " + date.getDate() + ", " + date.getFullYear() + " " + fmt_time(date, H_24);
|
||||
var str = MONTHS[date.getMonth()] + " " + date.getDate();
|
||||
// include year if message date is from a previous year
|
||||
if (is_older_year) {
|
||||
str += ", " + date.getFullYear();
|
||||
}
|
||||
str += " " + fmt_time(date, H_24);
|
||||
return str;
|
||||
};
|
||||
}());
|
||||
|
||||
|
||||
Reference in New Issue
Block a user