mirror of
https://github.com/tcsenpai/swingmusic.git
synced 2025-07-29 14:12:21 +00:00
update formatSeconds() to correct grammar
This commit is contained in:
parent
6fcca991b8
commit
5450a190f3
@ -213,15 +213,37 @@ window.addEventListener("keyup", () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
function formatSeconds(seconds) {
|
function formatSeconds(seconds) {
|
||||||
|
// check if there are arguments
|
||||||
|
|
||||||
const date = new Date(seconds * 1000);
|
const date = new Date(seconds * 1000);
|
||||||
|
|
||||||
const hh = date.getUTCHours();
|
const hh = date.getUTCHours();
|
||||||
const mm = date.getUTCMinutes();
|
const mm = date.getUTCMinutes();
|
||||||
const ss = date.getUTCSeconds();
|
const ss = date.getUTCSeconds();
|
||||||
|
|
||||||
const _hh = hh < 10 ? `0${hh}` : hh;
|
let _hh = hh < 10 ? `0${hh}` : hh;
|
||||||
const _mm = mm < 10 ? `0${mm}` : mm;
|
let _mm = mm < 10 ? `0${mm}` : mm;
|
||||||
const _ss = ss < 10 ? `0${ss}` : ss;
|
let _ss = ss < 10 ? `0${ss}` : ss;
|
||||||
|
|
||||||
|
if (arguments[1]) {
|
||||||
|
if (hh === 1) {
|
||||||
|
_hh = hh + " Hour";
|
||||||
|
} else {
|
||||||
|
_hh = `${hh} Hours`;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (mm === 1) {
|
||||||
|
_mm = mm + " Minute";
|
||||||
|
} else {
|
||||||
|
_mm = `${mm} Minutes`;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (hh > 0) {
|
||||||
|
return `${_hh}, ${_mm}`;
|
||||||
|
} else {
|
||||||
|
return `${_mm}`;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (hh > 0) {
|
if (hh > 0) {
|
||||||
return `${_hh}:${_mm}:${_ss}`;
|
return `${_hh}:${_mm}:${_ss}`;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user