Skip to content

Commit

Permalink
Merge pull request #213 from bcc-code/fix-time-duration-component
Browse files Browse the repository at this point in the history
Fix time duration
  • Loading branch information
SimonSimCity authored Sep 16, 2023
2 parents bb8e60b + 7d7bb23 commit 284ec84
Showing 1 changed file with 10 additions and 7 deletions.
17 changes: 10 additions & 7 deletions components/TimeDuration.vue
Original file line number Diff line number Diff line change
@@ -1,13 +1,16 @@
<script setup lang="ts">
defineProps<{
const props = defineProps<{
duration: number;
}>();
const timeAsText = computed(() =>
!Number.isFinite(props.duration)
? "--:--"
: `${`${Math.floor(props.duration / 60)}`.padStart(2, "0")}:${`${Math.floor(
props.duration % 60
)}`.padStart(2, "0")}`
);
</script>
<template>
<template v-if="!Number.isFinite(duration)">--:--</template>
<template v-else>
{{ (duration / 60).toFixed(0).padStart(2, "0") }}:{{
(duration % 60).toFixed(0).padStart(2, "0")
}}
</template>
{{ timeAsText }}
</template>

0 comments on commit 284ec84

Please sign in to comment.