-
Notifications
You must be signed in to change notification settings - Fork 18
Open
Description
I’m trying to create a TZDate instance and compare it with other dates.
However, it looks like the instantiation from TZDate isn’t handling daylight savings time (DST) correctly.
import { parseISO } from 'date-fns';
import { tz, TZDate } from '@date-fns/tz';
const instantiation = new TZDate('2025-10-04T23:59:00', 'Europe/Copenhagen');
/**
* TZDate 2025-10-04T22:59:00.000Z {
* timeZone: 'Europe/Copenhagen',
* internal: 2025-10-05T00:59:00.000Z
* }
*/
const parsedInstance = parseISO(timestring, { in: tz(iana) });
/**
* TZDate 2025-10-04T21:59:00.000Z {
* timeZone: 'Europe/Copenhagen',
* internal: 2025-10-04T23:59:00.000Z
* }
*/Based on timeanddate.com’s converter, the conversion suggests a mismatch.
Dependencies
"dependencies": {
"@date-fns/tz": "^1.4.1",
"@date-fns/utc": "^2.1.1",
"date-fns": "^4.1.0"
}Hasan-Mir
Metadata
Metadata
Assignees
Labels
No labels