iamkun / iamkun/dayjs

dayjs('2020-12', 'YYYY-ww').format('YYYY-ww') not equal to '2020-12'

Open
#2,358 0 comments 3 reactions 0 assignees View on GitHub
Dominant language
JavaScript
Stars
48.7k
Forks
2.5k
PR merge metrics
No merged PRs in 30d

Description

**Describe the bug**
```
import advancedFormat from 'dayjs/plugin/advancedFormat';
import isoWeeksInYear from 'dayjs/plugin/isoWeeksInYear';
import customParseFormat from 'dayjs/plugin/customParseFormat';
import weekYear from 'dayjs/plugin/weekYear';
import weekOfYear from 'dayjs/plugin/weekOfYear';
import isoWeek from 'dayjs/plugin/isoWeek';
import dayjs from 'dayjs';
dayjs.extend(advancedFormat)
dayjs.extend(customParseFormat)
dayjs.extend(weekYear)
dayjs.extend(weekOfYear)
dayjs.extend(isoWeek)
dayjs.extend(isoWeeksInYear)

console.log(dayjs('2020-12', 'YYYY-ww', true).format('YYYY-ww') ==='2020-12')
// false
```

**Expected behavior**
week formater cannot self-format

**Information**
- Day.js Version [v1.11.8]
- OS: [macos ]
- Browser [chrome 114.0.5735.133]
- Time zone: [every]

Contributor guide

Open the contributing guide

Research direction

Reproduce the example with the listed Day.js plugins, starting with customParseFormat, weekYear, weekOfYear, and isoWeek. Trace the parsing and formatting paths for the YYYY-ww tokens in those plugin entry points. Done means the strict parse of '2020-12' formats back to '2020-12' and the relevant tests pass.

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
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.