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

Should .parse() return false? #2

Closed
caneco opened this issue Mar 17, 2015 · 1 comment
Closed

Should .parse() return false? #2

caneco opened this issue Mar 17, 2015 · 1 comment

Comments

@caneco
Copy link

caneco commented Mar 17, 2015

Hello!
I was trying to make the following instruction and got the following output.

fecha.parse('2015-02-29')
// Sun Mar 01 2015 00:00:00 GMT+0000 (WET)

Souldn't return false instead of the next day?

@taylorhakes
Copy link
Owner

Unfortunately, that is the correct behavior. See this behavior https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/parse#ECMAScript_5_ISO-8601_format_support

fecha falls back native Date.parse if you don't specify a format. You found the very strange behavior with ISO date formats. With ISO date formats Date.parse assumes UTC time and then converts to local time, which causes the weird result. Luckily in ES6 the behavior is different.

I am going to deprecate and add a warning if a format is not specified. In the next major version I will throw a hard error if a format is not specified. It should limit the confusion you experienced.

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

2 participants