feat: use useNow to provide auto updates

This commit is contained in:
kolaente 2021-12-30 17:18:57 +01:00
parent 4a912a91d7
commit 2c36356f3f
Signed by untrusted user: konrad
GPG Key ID: F40E70337AB24C9B
1 changed files with 5 additions and 2 deletions

View File

@ -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<Date> = useNow()): String {
const hours = now instanceof Date ? new Date(now).getHours() : new Date(now.value).getHours()
if (hours < 5) {
return `${TRANSLATION_KEY_PREFIX}Night`