marnusw/date-fns-tz

date-fns-tz does not consider Daylight Saving Time in my country

Mohamed-Mayallo opened this issue · 3 comments

My country (Egypt) has restored Daylight Saving Time after a long pause. My app now is not working properly like before because of the timezone shifting.

The timezone was +02:00 but now it is actually +03:00, however, date-fns-tz is still considering it +02:00.

Hello, I recommend using Luxon as it works correctly!
https://www.npmjs.com/package/luxon

import {DateTime} from "luxon"

console.log(DateTime.utc().toISO())

console.log(DateTime.now().setZone('Africa/Cairo').toISO())

I have the same issue in my country(italy):

const inputFromBackend = {
    start: '14:30:00',
    end: '18:45:00',
}

// 2.
let startHours = inputFromBackend.start.split(':').map(Number)
let endHours = inputFromBackend.end.split(':').map(Number)
let time = {
    start: new Date(Date.UTC(1970, 0, 1, startHours[0], startHours[1], startHours[2])).toISOString(),
    end: new Date(Date.UTC(1970, 0, 1, endHours[0], endHours[1], endHours[2])).toISOString()
}
console.log(time)

const fullLocalTime = {
    localStart: formatInTimeZone(time.start, timeZone, 'yyyy-MM-dd HH:mm:ss zzz', { locale: itIT }),
    localEnd: formatInTimeZone(time.end, timeZone, 'yyyy-MM-dd HH:mm:ss zzz', { locale: enGB }),
}

console.log(fullLocalTime)
2024-05-21T09:20:53.902Z
Europe/Rome
{
  start: "1970-01-01T14:30:00.000Z",
  end: "1970-01-01T18:45:00.000Z",
}
{
  localStart: "1970-01-01 15:30:00 CET", 
  localEnd: "1970-01-01 19:45:00 CET",
}

localStart and localEnd should be CEST not CET!
Here the table where italy switchs timezone

Just my comments here. The date-fns rely mostly on JS native Date and Intl support, so to get this fixed you most likely have to update your browser, or NodeJS version with version that has the Intl implementation adjusted to any changes in the DST logic.