user settings: fix uploaded files UI

Fix UI and date uploaded
This commit is contained in:
Utkarsh Patil
2017-12-08 17:24:32 +04:00
committed by showell
parent b3d7a87552
commit c9596e12be
5 changed files with 31 additions and 64 deletions

View File

@@ -8,9 +8,6 @@ var set_to_start_of_day = function (time) {
return time.setMilliseconds(0).setSeconds(0).setMinutes(0).setHours(0);
};
var MONTHS = ["Jan", "Feb", "Mar", "Apr", "May", "Jun",
"Jul", "Aug", "Sep", "Oct", "Nov", "Dec"];
// Given an XDate object 'time', returns an object:
// {
// time_str: a string for the current human-formatted version
@@ -217,6 +214,9 @@ exports.get_full_time = function (timestamp) {
// this is for rendering absolute time based off the preferences for twenty-four
// hour time in the format of "%mmm %d, %h:%m %p".
exports.absolute_time = (function () {
var MONTHS = ["Jan", "Feb", "Mar", "Apr", "May", "Jun",
"Jul", "Aug", "Sep", "Oct", "Nov", "Dec"];
var fmt_time = function (date, H_24) {
var payload = {
hours: date.getHours(),
@@ -254,31 +254,6 @@ exports.absolute_time = (function () {
};
}());
// this is for rendering date relative to current time
// and should display "Today" or "Yesterday" if timestamp date is
// today's or yesterday's, if not display the format "%mmm %d".
exports.relative_date = function (timestamp, today) {
if (typeof today === 'undefined') {
today = new Date();
}
var date = new Date(timestamp);
if ((today.getMonth() === date.getMonth()) && (today.getFullYear() === date.getFullYear())) {
var date_diff = today.getDate() - date.getDate();
if (date_diff === 0) {
return "Today";
} else if (date_diff === 1) {
return "Yesterday";
}
}
var is_older_year = (today.getFullYear() - date.getFullYear()) > 0;
var str = MONTHS[date.getMonth()] + " " + date.getDate();
// include year if message date is from a previous year
if (is_older_year) {
str += ", " + date.getFullYear();
}
return str;
};
// XDate.toLocaleDateString and XDate.toLocaleTimeString are
// expensive, so we delay running the following code until we need
// the full date and time strings.