daysbooked in timezone Europe/Berlin

This commit is contained in:
Thomas Ruoff
2020-11-09 22:51:19 +01:00
parent e9a8dfaf32
commit cd6ae123bb
4 changed files with 15 additions and 2 deletions

View File

@@ -1,4 +1,5 @@
import { parse, format, addDays } from 'date-fns'
import { utcToZonedTime } from 'date-fns-tz'
const FRONTEND_FORMAT = 'dd.MM.yyyy'
const BACKEND_FORMAT = 'yyyy-MM-dd'
@@ -66,3 +67,8 @@ function dateParse(input: string, formatString: string) {
export function dateParseFrontend(input: string) {
return dateParse(input, FRONTEND_FORMAT)
}
export function nowInTz(timezone = 'Europe/Berlin') {
const now = new Date()
return utcToZonedTime(now, timezone)
}