{"action":"created","issue":{"url":"https://api.github.com/repos/iamkun/dayjs/issues/361","repository_url":"https://api.github.com/repos/iamkun/dayjs","labels_url":"https://api.github.com/repos/iamkun/dayjs/issues/361/labels{/name}","comments_url":"https://api.github.com/repos/iamkun/dayjs/issues/361/comments","events_url":"https://api.github.com/repos/iamkun/dayjs/issues/361/events","html_url":"https://github.com/iamkun/dayjs/issues/361","id":365500517,"node_id":"MDU6SXNzdWUzNjU1MDA1MTc=","number":361,"title":"Inconsistent constructor behavior around `undefined` and `null`","user":{"login":"jsumners","id":321201,"node_id":"MDQ6VXNlcjMyMTIwMQ==","avatar_url":"https://avatars1.githubusercontent.com/u/321201?v=4","gravatar_id":"","url":"https://api.github.com/users/jsumners","html_url":"https://github.com/jsumners","followers_url":"https://api.github.com/users/jsumners/followers","following_url":"https://api.github.com/users/jsumners/following{/other_user}","gists_url":"https://api.github.com/users/jsumners/gists{/gist_id}","starred_url":"https://api.github.com/users/jsumners/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jsumners/subscriptions","organizations_url":"https://api.github.com/users/jsumners/orgs","repos_url":"https://api.github.com/users/jsumners/repos","events_url":"https://api.github.com/users/jsumners/events{/privacy}","received_events_url":"https://api.github.com/users/jsumners/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":0,"created_at":"2018-10-01T14:54:12Z","updated_at":"2018-10-14T18:17:21Z","closed_at":null,"author_association":"NONE","body":"```\r\n> assert.ok(dayjs(undefined).isValid())\r\nundefined\r\n> assert.ok(dayjs(null).isValid())\r\nAssertionError [ERR_ASSERTION]: false == true\r\n```\r\n\r\nIn other words, `dayjs(undefined)` results in an instance at the current date and time whereas `dayjs(null)` results in an invalid date. I think both should result in an invalid date."},"comment":{"url":"https://api.github.com/repos/iamkun/dayjs/issues/comments/429649140","html_url":"https://github.com/iamkun/dayjs/issues/361#issuecomment-429649140","issue_url":"https://api.github.com/repos/iamkun/dayjs/issues/361","id":429649140,"node_id":"MDEyOklzc3VlQ29tbWVudDQyOTY0OTE0MA==","user":{"login":"prantlf","id":733193,"node_id":"MDQ6VXNlcjczMzE5Mw==","avatar_url":"https://avatars0.githubusercontent.com/u/733193?v=4","gravatar_id":"","url":"https://api.github.com/users/prantlf","html_url":"https://github.com/prantlf","followers_url":"https://api.github.com/users/prantlf/followers","following_url":"https://api.github.com/users/prantlf/following{/other_user}","gists_url":"https://api.github.com/users/prantlf/gists{/gist_id}","starred_url":"https://api.github.com/users/prantlf/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/prantlf/subscriptions","organizations_url":"https://api.github.com/users/prantlf/orgs","repos_url":"https://api.github.com/users/prantlf/repos","events_url":"https://api.github.com/users/prantlf/events{/privacy}","received_events_url":"https://api.github.com/users/prantlf/received_events","type":"User","site_admin":false},"created_at":"2018-10-14T18:17:21Z","updated_at":"2018-10-14T18:17:21Z","author_association":"CONTRIBUTOR","body":"This is \"as-designed\". Day.js is meant to be a lightweight and immutable replacement of Moment.js. It means keeping the interface as compatible as possible.\r\n\r\n```\r\n> dayjs().toDate()\r\n2018-10-14T18:13:40.428Z\r\n> dayjs(undefined).toDate()\r\n2018-10-14T18:13:44.140Z\r\n> dayjs(null).toDate()\r\nInvalid Date\r\n```\r\n\r\n```\r\n> moment()\r\nmoment(\"2018-10-14T20:11:41.383\")\r\n> moment(undefined)\r\nmoment(\"2018-10-14T20:11:44.558\")\r\n> moment(null)\r\nmoment.invalid(/* NaN */)\r\n```\r\n\r\nUnfortunately, it makes the constructor incompatible with the native `Date` object. You cannot have both.\r\n\r\n```\r\n> new Date()\r\n2018-10-14T18:10:28.471Z\r\n> new Date(undefined)\r\nInvalid Date\r\n> new Date(null)\r\n1970-01-01T00:00:00.000Z\r\n```\r\n\r\nBy the way, the behaviour of the `Date` object is not intuitive either ;-)"}}
{"actor":{"display_login":"prantlf"}}