Bad judgment :isValid
Describe the bug A clear and concise description of what the bug is.
Expected behavior A clear and concise description of what you expected to happen.
Information
- Day.js Version [e.g. v1.11.13]
- OS: [e.g. win]
- Browser [e.g. chrome 113]
- Time zone: [e.g. GMT-07:00 DST (Pacific Daylight Time)]
I don't think this is a bug, because when we start a Date Object with a number, it is read as if it were milliseconds. For example: JavaScript is based on Epoch Time, so new Date(0) is like 1970-01-01 00:00:00 and new Date(1000) is like 1970-01-01 00:00:01.
String.prototype.isValid = function() { return this.length > 0; //a demo };
I don't think this is a bug, because when we start a Date Object with a number, it is read as if it were milliseconds. For example: JavaScript is based on Epoch Time, so new Date(0) is like 1970-01-01 00:00:00 and new Date(1000) is like 1970-01-01 00:00:01.
I agree, it is not a bug, it is just poorly designed.
dayjs(v, 'YYYY-MM-DDTHH:mm:ssZ', true).isValid() -> true makes the isValid() fn useless, even in strict mode
I would recommend not using .isValid() at all and use regex instead.