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 validation may not be strict enough #61

Closed
axic opened this issue Oct 25, 2012 · 1 comment
Closed

Parsing validation may not be strict enough #61

axic opened this issue Oct 25, 2012 · 1 comment

Comments

@axic
Copy link

axic commented Oct 25, 2012

The date parsing feature may not be strict enough:

  • moment("20120101") gives Invalid Date (probably it would understand it as unix time?)
  • moment("2012-01-01") parses the date correctly
  • moment("20120101", "YYYYMMDD") parses it correctly as well

However with a bogus date string I noticed an odd behaviour:

  • moment("a") correctly gives Invalid Date
  • moment("a", "YYYYMMDD") on the other hand results in: Sat Jan 01 0 00:00:00 GMT+0000 (GMT)

I really hoped the date parsing would do some validity checks for me (e.g. check against the length specified in the format and check for numbers vs. strings).

Is this the desired behaviour or a bug?

Also: moment("") and moment(null) both result in null being returned. For an empty string should that be null or Invalid Date?

@axic
Copy link
Author

axic commented Oct 25, 2012

I am so sorry this went to the wrong project :)

@axic axic closed this as completed Oct 25, 2012
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