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

Comments

Projects
None yet
3 participants
@andjd

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

This comment has been minimized.

Member

icambron commented Dec 4, 2016

I think returning null is probably reasonable here.

@maggiepint

This comment has been minimized.

Member

maggiepint commented Jan 9, 2017

Closed in favor of #3710

@maggiepint maggiepint closed this Jan 9, 2017

ichernev added a commit that referenced this issue Mar 2, 2017

Merge pull request #3710 from moment:maggie/isostringnull
[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