calculate playlist duration

- use python's `sum()` method to add durations instead of for loop
This commit is contained in:
geoffrey45
2022-07-02 13:19:09 +03:00
committed by Mungai Geoffrey
parent 5bc0eaf8e6
commit b318c0d324
7 changed files with 27 additions and 25 deletions
+3 -1
View File
@@ -27,7 +27,8 @@
<span v-else-if="props.info.count == 1"
>{{ props.info.count }} Track</span
>
<span v-else>{{ props.info.count }} Tracks</span> 3 Hours
<span v-else>{{ props.info.count }} Tracks</span>
{{ formatSeconds(props.info.duration, true) }}
</div>
<div class="desc">
{{ props.info.description }}
@@ -58,6 +59,7 @@ import useContextStore from "../../stores/context";
import useModalStore from "../../stores/modal";
import Option from "../shared/Option.vue";
import PlayBtnRect from "../shared/PlayBtnRect.vue";
import { formatSeconds } from "@/composables/perks";
const imguri = paths.images.playlist;
const context = useContextStore();
+5 -2
View File
@@ -37,9 +37,12 @@ function getElem(id: string, type: string) {
}
}
/**
* Converts seconds into minutes and hours.
* @param seconds The seconds to convert
* @param long Whether to provide the time in the long format
*/
function formatSeconds(seconds: number, long?: boolean) {
// check if there are arguments
const date = new Date(seconds * 1000);
const hh = date.getUTCHours();
+1
View File
@@ -64,6 +64,7 @@ export interface Playlist {
count?: number;
lastUpdated?: string;
thumb?: string;
duration?: number
}
export interface Notif {