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

Parsing a date using fromUTC not working as expected #651

Open
raquelgs opened this issue Jun 13, 2019 · 0 comments
Open

Parsing a date using fromUTC not working as expected #651

raquelgs opened this issue Jun 13, 2019 · 0 comments

Comments

@raquelgs
Copy link

When setting the locale to en-GB the date is parsed 4 hours before expected:

const stringDate = "05/22/2000";
const gb = Sugar.Date.create(stringDate, { fromUTC: true, locale: "en-GB" });
const us = Sugar.Date.create(stringDate, { fromUTC: true, locale: "en-US" });

console.log(gb.toISOString());
// Output: 2000-05-21T20:00:00.000Z 
console.log(us.toISOString());
// Output: 2000-05-22T00:00:00.000Z 

We expect both console.log to be the identical (2000-05-22T00:00:00.000Z).

Is this the expected behaviour? If that's the case, do you know why setting locale to en-GB is changing the parsed date?

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

1 participant