diff --git a/src/renderer/index.js b/src/renderer/index.js index a42b1ece..4781149c 100644 --- a/src/renderer/index.js +++ b/src/renderer/index.js @@ -1579,8 +1579,11 @@ const app = new Vue({ getTotalTime() { try { 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); - return app.showingPlaylist.relationships.tracks.data.length + " tracks, " + time + " mins."; + let time = Math.round([].concat(...app.showingPlaylist.relationships.tracks.data).reduce((a, { attributes: { durationInMillis } }) => a + durationInMillis, 0) / 1000); + 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 "" } catch (err) { return "" diff --git a/src/renderer/views/pages/cider-playlist.ejs b/src/renderer/views/pages/cider-playlist.ejs index 07c28728..fc77ea6e 100644 --- a/src/renderer/views/pages/cider-playlist.ejs +++ b/src/renderer/views/pages/cider-playlist.ejs @@ -84,13 +84,13 @@
- {{data.attributes.releaseDate}} + {{getFormattedDate(data.attributes.releaseDate)}}
+
{{app.getTotalTime()}}
{{data.attributes.copyright}}
-
{{app.getTotalTime()}}
@@ -225,6 +225,17 @@ kind = data.attributes.playParams.kind; id = data.attributes.playParams.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 ""} } } })