dayjs icon indicating copy to clipboard operation
dayjs copied to clipboard

Check of an invalid date returns true on Firefox (isValid())

Open JSeifBY opened this issue 1 year ago • 1 comments

The Issue isValid() not behaving the same on different browser, it returns false on Chrome / Safari as expected but returns true on Firefox.

The string that was sent to the validator has no relation with dates "JUNKIE (SWE)", see screenshot:

Chrome: Chrome

Fiirefox: Firefox

Expected behavior An invalid date should always returns false on all browsers the same way.

Information

  • Day.js Version 1.10.7
  • OS: MacOS
  • Browser: Firefox 125.0.3
  • Time zone: UTC+2

JSeifBY avatar May 06 '24 09:05 JSeifBY

hi @JSeifBY, i'm facing the same issue as you.

the root cause is the difference between FireFox and Chrome engines.

you can try with this function

new Date('JUNKIE (SWE)')

on Chrome

  • expected: Invalid Date
  • actual: Invalid Date

Image

on Firefox

  • expected: Invalid Date
  • actual: Date Fri Jun 01 2001 00:00:00 GMT+0700 (Indochina Time)

Image

I think we should raise this issue with Mozilla 😂

vhnam avatar Mar 10 '25 06:03 vhnam