feat: use useNow to provide auto updates

This commit is contained in:
kolaente 2021-12-30 17:18:57 +01:00 committed by Gitea
parent 27534a98e9
commit d2577f1df6

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`