dayjs
dayjs copied to clipboard
Big Bug!!!!!! Date acquisition exception and parsing time exception
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.
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 But .get() cases is return error