Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
Mohamed-Mayallo opened this issue May 11, 2023 · 2 comments
Open

Comments

@Mohamed-Mayallo
Copy link

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.

@kareemotafy
Copy link

kareemotafy commented Jun 21, 2023

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())

@valentimarco
Copy link

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants