Skip to content

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

Description

@andjd

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

Activity

  1. icambron commented on Dec 4, 2016

    @icambron
    Contributor

    I think returning null is probably reasonable here.

  2. maggiepint commented on Jan 9, 2017

    @maggiepint
    Member

    Closed in favor of #3710

  3. added a commit that references this issue on Mar 2, 2017
    e4364f5
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions