There are conflict between advancedFormat and customParseFormat plugins when format dayjs object
- Dominant language
- JavaScript
- Stars
- 48.7k
- Forks
- 2.5k
- PR merge metrics
- No merged PRs in 30d
Description
**Describe the bug**
I use advancedFormat and customParseFormat, and format `2021-02-28T15:00:00.000Z` to `YYYY-W`.
```js
import * as dayjs from "dayjs";
import * as advancedFormat from "dayjs/plugin/advancedFormat";
import * as customParseFormat from "dayjs/plugin/customParseFormat";
import * as isoWeek from "dayjs/plugin/isoWeek";
import * as timezone from "dayjs/plugin/timezone";
import * as utc from "dayjs/plugin/utc";
dayjs.extend(advancedFormat);
dayjs.extend(customParseFormat);
dayjs.extend(isoWeek);
dayjs.extend(timezone);
dayjs.extend(utc);
const d = dayjs.unix(Number(1614524400)).tz("Asia/Tokyo");
console.log(d.toISOString());
console.log(d.format("YYYY-W"));
```
This result is
```
❯ TZ=UTC node index.js
2021-02-28T15:00:00.000Z
2021-8
```
Next, I remove `import * as customParseFormat from "dayjs/plugin/customParseFormat";`.
```js
import * as dayjs from "dayjs";
import * as advancedFormat from "dayjs/plugin/advancedFormat";
// import * as customParseFormat from "dayjs/plugin/customParseFormat";
import * as isoWeek from "dayjs/plugin/isoWeek";
import * as timezone from "dayjs/plugin/timezone";
import * as utc from "dayjs/plugin/utc";
dayjs.extend(advancedFormat);
// dayjs.extend(customParseFormat);
dayjs.extend(isoWeek);
dayjs.extend(timezone);
dayjs.extend(utc);
const d = dayjs.unix(Number(1614524400)).tz("Asia/Tokyo");
console.log(d.toISOString());
console.log(d.format("YYYY-W"));
```
And run this.
```
❯ TZ=UTC node dayjs.js
2021-02-28T15:00:00.000Z
2021-9
```
**Expected behavior**
I think both case should be `2021-9`
Reproduce repository is
**Information**
- Day.js Version [1.11.7]
- OS: [Mac]
- Browser [Node.js]
- Time zone: [Asia/Tokyo(But those example is set env vars TZ=UTC)]
Contributor guide
Research direction
Reproduce the Node.js example from the issue with Day.js 1.11.7, then compare formatting with and without the customParseFormat, advancedFormat, isoWeek, timezone, and utc plugins. Inspect the advancedFormat and customParseFormat plugin entry points; done means formatting YYYY-W produces 2021-9 consistently when both plugins are enabled.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- javascript
- Domain
- web-dev
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Clearly specified
- Newbie friendliness
- 55/100