dayjs icon indicating copy to clipboard operation
dayjs copied to clipboard

Big Bug!!!!!! Date acquisition exception and parsing time exception

Open smithyj opened this issue 1 year ago • 2 comments
trafficstars

Case:

dayjs(`0001-12-01 00:00:00`).get("year") // 1901
moment(`0001-12-01 00:00:00`).get("year") // 1,expected

Case:

dayjs(`0001-12-00 00:00:00`).get("year") // 1901
moment(`0001-12-00 00:00:00`).get("year") // NaN,expected

Case:

dayjs("1100-12-00 00:00:00").isValid() // true
moment("1100-12-00 00:00:00").isValid() // false,expected

Case:

dayjs("1100-00-00 00:00:00").isValid() // true
dayjs("1100-00-01 00:00:00").isValid() // true
moment("1100-00-00 00:00:00").isValid() // false,expected
moment("1100-00-01 00:00:00").isValid() // false,expected

Case:

dayjs("0000-00-00 00:00:00").isValid() // true
moment("0000-00-00 00:00:00").isValid() // false,expected

There are more cases with issues.

smithyj avatar May 20 '24 02:05 smithyj

Your cases of .isValid() API stuffs somehow not a bug, its a feature otherwise. You can check the code, they are using the regex to check your input as below /^(\d{4})[-/]?(\d{1,2})?[-/]?(\d{0,2})[Tt\s]*(\d{1,2})?:?(\d{1,2})?:?(\d{1,2})?[.:]?(\d+)?$/ I think .isValid() still cause some unexpected bugs cuz I faced some

mike-kaonashi avatar May 20 '24 09:05 mike-kaonashi

@mike-kaonashi But .get() cases is return error

smithyj avatar May 20 '24 10:05 smithyj