Resolved issues with hours, redid the function as epoch is a pain

Changed locale for en_GB to for songs instead of tracks
This commit is contained in:
Core 2022-03-14 09:26:48 +00:00
parent 8e4f2adfa7
commit 1b204726c6
2 changed files with 39 additions and 51 deletions

View file

@ -11,5 +11,7 @@
"settings.option.audio.enableAdvancedFunctionality.audioSpatialization": "Audio Spatialisation", "settings.option.audio.enableAdvancedFunctionality.audioSpatialization": "Audio Spatialisation",
"settings.option.audio.enableAdvancedFunctionality.audioSpatialization.description": "Spatialise audio and make audio more 3-dimensional (note: This is not Dolby Atmos)", "settings.option.audio.enableAdvancedFunctionality.audioSpatialization.description": "Spatialise audio and make audio more 3-dimensional (note: This is not Dolby Atmos)",
"spatial.notTurnedOn": "Audio Spatialisation is disabled. To use, please enable it first.", "spatial.notTurnedOn": "Audio Spatialisation is disabled. To use, please enable it first.",
"action.tray.minimize": "Minimise to Tray" "action.tray.minimize": "Minimise to Tray",
"term.track": "song",
"term.tracks": "songs"
} }

View file

@ -1400,72 +1400,58 @@ const app = new Vue({
} }
}, },
/** /**
* Converts seconds to dd:hh:mm:ss * Converts seconds to dd:hh:mm:ss / Days:Hours:Minutes:Seconds
* @param {number} time (in seconds) * @param {number} seconds
* @param {string} format (short, long) * @param {string} format (short, long)
* @returns {string} * @returns {string}
* @author Core#1034 * @author Core#1034
* @memberOf app * @memberOf app
*/ */
convertTime(time = 0, format = 'short') { convertTime(seconds, format = "short") {
if (isNaN(time)) { if (isNaN(seconds)) {
time = 0 seconds = 0
} }
if (typeof time !== "number") { seconds = parseInt(seconds);
time = parseInt(time)
const datetime = new Date(seconds * 1000)
if (format === "long") {
const d = Math.floor(seconds / (3600*24));
const h = Math.floor(seconds % (3600*24) / 3600);
const m = Math.floor(seconds % 3600 / 60);
const s = Math.floor(seconds % 60);
const dDisplay = d > 0 ? d + (d === 1 ? ` ${app.getLz("term.time.day")}, ` : ` ${app.getLz("term.time.days")}, `) : "";
const hDisplay = h > 0 ? h + (h === 1 ? ` ${app.getLz("term.time.hour")}, ` : ` ${app.getLz("term.time.hours")}, `) : "";
const mDisplay = m > 0 ? m + (m === 1 ? ` ${app.getLz("term.time.minute")}, ` : ` ${app.getLz("term.time.minutes")}, `) : "";
const sDisplay = s > 0 ? s + (s === 1 ? ` ${app.getLz("term.time.second")}` : ` ${app.getLz("term.time.seconds")}`) : "";
return dDisplay + hDisplay + mDisplay + sDisplay;
} }
else {
let returnTime = datetime.toISOString().substring(11, 19);
const timeGates = { const timeGates = {
600: 15, // 10 Minutes 600: 15, // 10 Minutes
3600: 14, // Hour 3600: 14, // Hour
36000: 12, // 10 Hours 36000: 12, // 10 Hours
}
const datetime = new Date(time * 1000)
let returnTime = datetime.toISOString().substring(11, 19);
for (let key in timeGates) {
if (time < key) {
returnTime = datetime.toISOString().substring(timeGates[key], 19)
break
}
}
// Add the days on the front
let day;
if (time >= 86400) {
day = datetime.toISOString().substring(8, 10)
day = parseInt(day) - 1
returnTime = day + ":" + returnTime
}
if (format === 'long') {
const longFormat = []
// Seconds
if (datetime.getSeconds() !== 0) {
longFormat.push(`${datetime.getSeconds()} ${app.getLz('term.time.seconds')}`)
} }
// Minutes for (let key in timeGates) {
if (time >= 60) { if (seconds < key) {
longFormat.push(`${datetime.getMinutes()} ${app.getLz(`term.time.${datetime.getMinutes() === 1 ? 'minute' : 'minutes'}`)}`) returnTime = datetime.toISOString().substring(timeGates[key], 19)
break
}
} }
// Hours // Add the days on the front
if (time >= 3600) { if (seconds >= 86400) {
longFormat.push(`${datetime.getHours()} ${app.getLz(`term.time.${datetime.getHours() === 1 ? 'hour' : 'hours'}`)}`) returnTime = parseInt(datetime.toISOString().substring(8, 10)) - 1 + ":" + returnTime
} }
// Days return returnTime
if (time >= 86400) {
longFormat.push(`${day} ${app.getLz(`term.time.${day === 1 ? 'day' : 'days'}`)}`)
}
returnTime = longFormat.reverse().join(', ')
} }
return returnTime
}, },
hashCode(str) { hashCode(str) {
let hash = 0, let hash = 0,