mirror of
https://github.com/jellyfin/jellyfin-web
synced 2025-03-30 19:56:21 +00:00
refactor date utils
This commit is contained in:
parent
a1c66f31fc
commit
2690381144
5 changed files with 40 additions and 20 deletions
|
@ -461,7 +461,7 @@ define(["datetime", "events", "itemHelper", "serverNotifications", "dom", "globa
|
|||
|
||||
if (!nowPlayingItem) {
|
||||
return {
|
||||
html: "Last seen " + humane_date(session.LastActivityDate),
|
||||
html: "Last seen " + humaneDate(session.LastActivityDate),
|
||||
image: imgUrl
|
||||
};
|
||||
}
|
||||
|
|
|
@ -86,7 +86,7 @@ define(["loading", "dom", "libraryMenu", "globalize", "scripts/imagehelper", "hu
|
|||
deviceHtml += "<div class='cardText cardText-secondary'>";
|
||||
if (device.LastUserName) {
|
||||
deviceHtml += device.LastUserName;
|
||||
deviceHtml += ", " + humane_date(device.DateLastActivity);
|
||||
deviceHtml += ", " + humaneDate(device.DateLastActivity);
|
||||
}
|
||||
deviceHtml += " ";
|
||||
deviceHtml += "</div>";
|
||||
|
|
|
@ -62,23 +62,11 @@ define(["jQuery", "loading", "events", "globalize", "serverNotifications", "huma
|
|||
page.querySelector(".divScheduledTasks").innerHTML = html;
|
||||
}
|
||||
|
||||
function humane_elapsed(firstDateStr, secondDateStr) {
|
||||
var dt1 = new Date(firstDateStr),
|
||||
dt2 = new Date(secondDateStr),
|
||||
seconds = (dt2.getTime() - dt1.getTime()) / 1e3,
|
||||
numdays = Math.floor(seconds % 31536e3 / 86400),
|
||||
numhours = Math.floor(seconds % 31536e3 % 86400 / 3600),
|
||||
numminutes = Math.floor(seconds % 31536e3 % 86400 % 3600 / 60),
|
||||
numseconds = Math.round(seconds % 31536e3 % 86400 % 3600 % 60),
|
||||
elapsedStr = "";
|
||||
return elapsedStr += 1 == numdays ? numdays + " day " : "", elapsedStr += numdays > 1 ? numdays + " days " : "", elapsedStr += 1 == numhours ? numhours + " hour " : "", elapsedStr += numhours > 1 ? numhours + " hours " : "", elapsedStr += 1 == numminutes ? numminutes + " minute " : "", elapsedStr += numminutes > 1 ? numminutes + " minutes " : "", elapsedStr += elapsedStr.length > 0 ? "and " : "", elapsedStr += 1 == numseconds ? numseconds + " second" : "", elapsedStr += 0 == numseconds || numseconds > 1 ? numseconds + " seconds" : ""
|
||||
}
|
||||
|
||||
function getTaskProgressHtml(task) {
|
||||
var html = "";
|
||||
if (task.State === "Idle") {
|
||||
if (task.LastExecutionResult) {
|
||||
html += globalize.translate("LabelScheduledTaskLastRan").replace("{0}", humane_date(task.LastExecutionResult.EndTimeUtc)).replace("{1}", humane_elapsed(task.LastExecutionResult.StartTimeUtc, task.LastExecutionResult.EndTimeUtc));
|
||||
html += globalize.translate("LabelScheduledTaskLastRan").replace("{0}", humaneDate(task.LastExecutionResult.EndTimeUtc)).replace("{1}", humaneElapsed(task.LastExecutionResult.StartTimeUtc, task.LastExecutionResult.EndTimeUtc));
|
||||
if (task.LastExecutionResult.Status === "Failed") {
|
||||
html += " <span style='color:#FF0000;'>(" + globalize.translate("LabelFailed") + ")</span>";
|
||||
} else if (task.LastExecutionResult.Status === "Cancelled") {
|
||||
|
|
|
@ -128,7 +128,7 @@ define(["loading", "dom", "globalize", "humanedate", "paper-icon-button-light",
|
|||
|
||||
function getLastSeenText(lastActivityDate) {
|
||||
if (lastActivityDate) {
|
||||
return "Last seen " + humane_date(lastActivityDate);
|
||||
return "Last seen " + humaneDate(lastActivityDate);
|
||||
}
|
||||
|
||||
return "";
|
||||
|
@ -207,7 +207,7 @@ define(["loading", "dom", "globalize", "humanedate", "paper-icon-button-light",
|
|||
|
||||
page.querySelector(".pending").innerHTML = users.map(getPendingUserHtml).join("");
|
||||
}
|
||||
|
||||
|
||||
// TODO cvium: maybe reuse for invitation system
|
||||
function cancelAuthorization(page, id) {
|
||||
loading.show();
|
||||
|
@ -230,7 +230,7 @@ define(["loading", "dom", "globalize", "humanedate", "paper-icon-button-light",
|
|||
// TODO cvium
|
||||
renderPendingGuests(page, []);
|
||||
// ApiClient.getJSON(ApiClient.getUrl("Connect/Pending")).then(function (pending) {
|
||||
//
|
||||
//
|
||||
// });
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue