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

`toDate` returns unexpected date in America/Sao_Paolo timezone. #992

Closed
inytar opened this issue Nov 29, 2018 · 2 comments

Comments

@inytar
Copy link

commented Nov 29, 2018

On daylight switching (2018-11-04) in Sao Paolo Brazil the toDate function returns a different date object then expected:

const toDate = require('date-fns/toDate');
const getDay = require('date-fns/getDay');

const nativeSunday = new Date(2018, 10, 4)
console.log(nativeSunday)
// 2018-11-04T03:00:00.000Z
console.log(getDay(nativeSunday))
// 0
const dateFnsSunday = toDate('2018-11-04')
console.log(dateFnsSunday)
// 2018-11-04T02:00:00.000Z
console.log(getDay(dateFnsSunday))
// 6

This problem only manifests itself if running in the Sao Paolo timezone. This can be tested by running:

env TZ='America/Sao_Paolo' node testScript.js
@inytar

This comment has been minimized.

Copy link
Author

commented Nov 29, 2018

#972 shows a similar issue for the formatting function.

@kossnocorp kossnocorp added the 🐛 Bug label Dec 7, 2018

kossnocorp added a commit that referenced this issue Dec 7, 2018

@kossnocorp kossnocorp added this to the v2 beta milestone Dec 10, 2018

@kossnocorp

This comment has been minimized.

Copy link
Member

commented Dec 11, 2018

This fix for this problem was released with v2.0.0-alpha.26 and v1.30.1.

See:

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
2 participants
You can’t perform that action at this time.