Dayjs: CustomParseFormat produces incorrect date

Created on 31 Jul 2019  路  3Comments  路  Source: iamkun/dayjs

Describe the bug
customParseFormat plugin produces different date when an invalid date is passed.
https://runkit.com/embed/k5j55xssyhfq

Expected behavior
It should produce Invalid date

Information

  • Day.js v1.8.15
  • OS: MacOS Mojave
  • Browser Chrome 76
  • Time zone: UTC+02:00

Most helpful comment

I fixed it temporarily by using a compare function before I go on in code, like:

(date, format) => dayjs(date, format).format(format) === date

This way I can meanwhile evaluate if the date is valid.
But I definitely think its a bug.

All 3 comments

I get something similar with a different format:

https://runkit.com/gopro16/5d4c7d6edc336b001a3f7f09

Same with: https://runkit.com/embed/qck0gd6k0opj

Actually you can put in garbage date and it makes it valid at leas that function does

I fixed it temporarily by using a compare function before I go on in code, like:

(date, format) => dayjs(date, format).format(format) === date

This way I can meanwhile evaluate if the date is valid.
But I definitely think its a bug.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

sheffieldnick picture sheffieldnick  路  5Comments

dakshshah96 picture dakshshah96  路  5Comments

Wyzix33 picture Wyzix33  路  4Comments

fundon picture fundon  路  5Comments

axelg12 picture axelg12  路  4Comments