Closed MartinX3 closed 1 year ago
This looks like a timezone issue. start
and end
are the UTC times corresponding to midnight in Germany's timezone (Central European Time).
Personally I would like to also see startDate
and endDate
properties that simply give the dates without worrying about the timezone. The current properties are useful if you want to test "is it before, during or after this holiday in Germany", but if you just want to list the dates they are confusing.
start
and end
are timestamps in UTC not timezones.
They'll give you the exact datetime of the holiday start and end.
For local purposes use date
.
// safe as date.js
const h = {
date: '2023-12-26 00:00:00',
start: '2023-12-25T23:00:00.000Z',
end: '2023-12-26T23:00:00.000Z',
name: '2. Weihnachtstag',
type: 'public',
rule: '12-26'
}
console.log('exact>', new Date(h.start).toString())
console.log('local>', new Date(h.date).toString())
// TZ=Europe/Berlin node date.js
// exact> Tue Dec 26 2023 00:00:00 GMT+0100 (Central European Standard Time)
// local> Tue Dec 26 2023 00:00:00 GMT+0100 (Central European Standard Time)
// TZ=Asia/Tokyo node date.js
// exact> Tue Dec 26 2023 08:00:00 GMT+0900 (Japan Standard Time)
// local> Tue Dec 26 2023 00:00:00 GMT+0900 (Japan Standard Time)
As example
It confuses me that start and end are on two different dates for a single day event. I'm not sure if holidays exist lasting more than a single day, but if they happen I don't know how to distinguish them.