mirror of
https://github.com/Forceu/Gokapi.git
synced 2026-05-12 17:40:08 -05:00
b761ee7d82
* Make dates in Upload view browser TZ, BREAKING change API output to UTC for ExpireAtString * Changed user and api key overview to local TZ, increased JS version * Fixed FileList API output to comply with API specs, fixed tests
37 lines
1.1 KiB
JavaScript
37 lines
1.1 KiB
JavaScript
function formatUnixTimestamp(unixTimestamp) {
|
|
const date = new Date(unixTimestamp * 1000);
|
|
const pad = (n) => String(n).padStart(2, '0');
|
|
|
|
const year = date.getFullYear();
|
|
const month = pad(date.getMonth() + 1); // months are 0-based
|
|
const day = pad(date.getDate());
|
|
const hours = pad(date.getHours());
|
|
const minutes = pad(date.getMinutes());
|
|
|
|
return `${year}-${month}-${day} ${hours}:${minutes}`;
|
|
}
|
|
|
|
function insertFormattedDate(unixTimestamp, id) {
|
|
document.getElementById(id).innerText = formatUnixTimestamp(unixTimestamp);
|
|
}
|
|
|
|
function insertLastOnlineDate(unixTimestamp, id) {
|
|
if (unixTimestamp == 0) {
|
|
document.getElementById(id).innerText = "Never";
|
|
return;
|
|
}
|
|
if ((Date.now()/1000) - 120 < unixTimestamp) {
|
|
document.getElementById(id).innerText = "Online";
|
|
return;
|
|
}
|
|
insertFormattedDate(unixTimestamp, id);
|
|
}
|
|
|
|
function insertLastUsed(unixTimestamp, id) {
|
|
if (unixTimestamp == 0) {
|
|
document.getElementById(id).innerText = "Never";
|
|
return;
|
|
}
|
|
insertFormattedDate(unixTimestamp, id);
|
|
}
|