V1.11.12 >>> ISO 8601 "YYYY-MM-DDTHH:mm:ssZ" BUG!
- Dominant language
- JavaScript
- Stars
- 48.7k
- Forks
- 2.5k
- PR merge metrics
- No merged PRs in 30d
Description
dayjs: v1.11.12
nodejs: v18.18.2
win11
```
"use strict";
const dayjs = require("dayjs");
const dayjs_timezone = require('dayjs/plugin/timezone');
const dayjs_utc = require('dayjs/plugin/utc');
const duration = require('dayjs/plugin/duration');
const customParseFormat = require('dayjs/plugin/customParseFormat');
dayjs.extend(duration);
dayjs.extend(dayjs_utc);
dayjs.extend(dayjs_timezone);
dayjs.extend(customParseFormat);
dayjs.tz.setDefault("Asia/Shanghai");
console.log(dayjs('2024-08-19T10:30:00Z', "YYYY-MM-DDTHH:mm:ssZ", true).isValid()); => false
M {
'$L': 'en',
'$u': undefined,
'$d': Invalid Date,
'$y': 2024,
'$M': 7,
'$D': 19,
'$W': 1,
'$H': 18,
'$m': 30,
'$s': 0,
'$ms': 0,
'$x': {},
'$isDayjsObject': true
}
console.log(dayjs.utc('2024-08-19T10:30:00Z', "YYYY-MM-DDTHH:mm:ssZ", true).isValid()); => dayjs.utc still false!
M {
'$L': 'en',
'$u': true,
'$d': Invalid Date,
'$y': 2024,
'$M': 7,
'$D': 19,
'$W': 1,
'$H': 10,
'$m': 30,
'$s': 0,
'$ms': 0,
'$x': {},
'$isDayjsObject': true
}
```
exinfo:
2024: Matches YYYY, representing the year.
08: Matches MM, representing the month of August.
19: Matches DD, representing the 19th day of the month.
T: The literal 'T' is correctly placed as the separator between the date and time.
10: Matches HH, representing the hour in 24-hour format.
30: Matches mm, representing the minutes past the hour.
00: Matches ss, representing the seconds.
Z: Indicates that the time is in UTC.
Contributor guide
Research direction
Reproduce the strict parsing calls shown for dayjs() and dayjs.utc() with the customParseFormat, utc, and timezone plugins enabled. Compare the documented ISO 8601 expectation with the false validity results, then add regression coverage for the affected parsing behavior and confirm both calls produce the intended validity result.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- javascript, nodejs
- Domain
- api
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Quiet
- Clarity
- Mostly clear
- Newbie friendliness
- 58/100