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
Closed

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

inytar opened this issue Nov 29, 2018 · 2 comments
Labels
Milestone

Comments

@inytar
Copy link

inytar 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
Copy link
Author

inytar commented Nov 29, 2018

#972 shows a similar issue for the formatting function.

kossnocorp added a commit that referenced this issue Dec 7, 2018
@kossnocorp kossnocorp added this to the v2 beta milestone Dec 10, 2018
@kossnocorp
Copy link
Member

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
Labels
Projects
None yet
Development

No branches or pull requests

2 participants