marnusw / date-fns-tz

Complementary library for date-fns v2 adding IANA time zone support
MIT License
1.06k stars 116 forks source link

formatInTimeZone considers DTS even on UTC when the env TZ has DTS #252

Open gabrielbull opened 1 year ago

gabrielbull commented 1 year ago

Consider this code in node:

process.env.TZ = "America/New_York";

const { parseISO } = require("date-fns");
const { formatInTimeZone } = require("date-fns-tz");

console.log(formatInTimeZone(parseISO("2024-03-09T02:00:00.000Z"), "UTC", "h:mm aaaa"));
console.log(formatInTimeZone(parseISO("2024-03-10T02:00:00.000Z"), "UTC", "h:mm aaaa"));

Outputs this:

2:00 a.m.
3:00 a.m.

But should output this:

2:00 a.m.
2:00 a.m.

The same issue is reproducible in the browser when the user has a timezone that has DTS.

crhistianramirez commented 11 months ago

I'm experiencing the same issue