convert total time to hms
This commit is contained in:
parent
907ea987c0
commit
5d3db3360d
2 changed files with 18 additions and 4 deletions
|
@ -1579,8 +1579,11 @@ const app = new Vue({
|
||||||
getTotalTime() {
|
getTotalTime() {
|
||||||
try {
|
try {
|
||||||
if (app.showingPlaylist.relationships.tracks.data.length > 0) {
|
if (app.showingPlaylist.relationships.tracks.data.length > 0) {
|
||||||
time = Math.round([].concat(...app.showingPlaylist.relationships.tracks.data).reduce((a, { attributes: { durationInMillis } }) => a + durationInMillis, 0) / 60000);
|
let time = Math.round([].concat(...app.showingPlaylist.relationships.tracks.data).reduce((a, { attributes: { durationInMillis } }) => a + durationInMillis, 0) / 1000);
|
||||||
return app.showingPlaylist.relationships.tracks.data.length + " tracks, " + time + " mins.";
|
let hours = Math.floor(time / 3600)
|
||||||
|
let mins = Math.floor(time / 60) % 60
|
||||||
|
let secs = time % 60
|
||||||
|
return app.showingPlaylist.relationships.tracks.data.length + " tracks, " + ((hours > 0) ? (hours + (" hour" + ((hours > 1) ? "s, " : ", "))) : "" ) + ((mins > 0) ? (mins + (" minute" + ((mins > 1) ? "s, " : ", "))) : "" )+ secs + (" second" + ((secs > 1) ? "s." : "."));
|
||||||
} else return ""
|
} else return ""
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
return ""
|
return ""
|
||||||
|
|
|
@ -84,13 +84,13 @@
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
<div class="playlist-time">
|
<div class="playlist-time">
|
||||||
{{data.attributes.releaseDate}}
|
{{getFormattedDate(data.attributes.releaseDate)}}
|
||||||
</div>
|
</div>
|
||||||
|
<div class="playlist-time total">{{app.getTotalTime()}}</div>
|
||||||
<div class="playlist-time item-navigate" @click="app.searchAndNavigate(data,'recordLabel') "
|
<div class="playlist-time item-navigate" @click="app.searchAndNavigate(data,'recordLabel') "
|
||||||
style="width: 50%;">
|
style="width: 50%;">
|
||||||
{{data.attributes.copyright}}
|
{{data.attributes.copyright}}
|
||||||
</div>
|
</div>
|
||||||
<div class="playlist-time">{{app.getTotalTime()}}</div>
|
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
</div>
|
</div>
|
||||||
|
@ -225,6 +225,17 @@
|
||||||
kind = data.attributes.playParams.kind;
|
kind = data.attributes.playParams.kind;
|
||||||
id = data.attributes.playParams.id;
|
id = data.attributes.playParams.id;
|
||||||
return `${kind}:${id}`
|
return `${kind}:${id}`
|
||||||
|
},
|
||||||
|
getFormattedDate: function (date) {
|
||||||
|
if (date == null || date === "") return "";
|
||||||
|
try{
|
||||||
|
var releaseDate = new Date(date);
|
||||||
|
month = new Intl.DateTimeFormat('en-US', { month: 'long'}).format(releaseDate);
|
||||||
|
date = releaseDate.getDate();
|
||||||
|
year = releaseDate.getFullYear();
|
||||||
|
|
||||||
|
return date + " " + month + " " + year;
|
||||||
|
} catch (e){ return ""}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue