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

toISOString shouldn't return "Invalid Date" when called on a invalid moment #3632

Closed
andjd opened this issue Nov 30, 2016 · 2 comments
Closed

Comments

@andjd
Copy link

andjd commented Nov 30, 2016

Because ISO dates are typically not used for direct human consumption and rather as a data interchange format, returning the string "Invalid Date" isn't very useful. Throwing a RangeError (which the native JS date object does) or returning null or would be more useful.

Description of the Issue and Steps to Reproduce:
create an invalid moment object (e.g. moment(null) or moment("0000-00-00"))
call toISOString on the invalid moment
see the string 'Invalid Date' is returned

Environment:

Chrome on Fedora

@icambron
Copy link
Member

icambron commented Dec 4, 2016

I think returning null is probably reasonable here.

@maggiepint
Copy link
Member

Closed in favor of #3710

ichernev added a commit that referenced this issue Mar 2, 2017
[bugfix] Fixes #3632, toISOString returns null for invalid date
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants