display when the target has passed

This commit is contained in:
Julien Calixte
2023-03-18 14:17:09 +01:00
parent 60991e08da
commit 784e54bbf8
4 changed files with 25 additions and 8 deletions

View File

@@ -1,8 +1,11 @@
import { ref, computed, onUnmounted, ComputedRef } from "vue"
import { timeUntil } from "../services/time-until"
import { hasTimePassed, timeUntil } from "../services/time-until"
export const useTimeUntil = (target: ComputedRef<string | undefined>) => {
const timeUntilTarget = target.value ? timeUntil(target.value) : null
const hasTargetPassed = timeUntilTarget
? hasTimePassed(timeUntilTarget)
: false
const yearsUntil = ref(timeUntilTarget?.years ?? 0)
const monthsUntil = ref(timeUntilTarget?.months ?? 0)
@@ -46,6 +49,7 @@ export const useTimeUntil = (target: ComputedRef<string | undefined>) => {
return {
timeUntilTarget,
hasTargetPassed,
isYearsDisplayed,
isMonthsDisplayed,
isDaysDisplayed,