From d2577f1df6d47363db2770b6c8a0b95ef6ea5ea8 Mon Sep 17 00:00:00 2001 From: kolaente Date: Thu, 30 Dec 2021 17:18:57 +0100 Subject: [PATCH] feat: use useNow to provide auto updates --- src/helpers/hourToSalutation.ts | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/helpers/hourToSalutation.ts b/src/helpers/hourToSalutation.ts index 96eca46c..68a866f6 100644 --- a/src/helpers/hourToSalutation.ts +++ b/src/helpers/hourToSalutation.ts @@ -1,7 +1,10 @@ +import {useNow} from '@vueuse/core' +import {Ref} from 'vue' + const TRANSLATION_KEY_PREFIX = 'home.welcome' -export function hourToSalutation(now: Date = new Date()): String { - const hours = new Date(now).getHours() +export function hourToSalutation(now: Date | Ref = useNow()): String { + const hours = now instanceof Date ? new Date(now).getHours() : new Date(now.value).getHours() if (hours < 5) { return `${TRANSLATION_KEY_PREFIX}Night`