BC year formatted as 'YYYY' abnormally
- Dominant language
- JavaScript
- Stars
- 48.7k
- Forks
- 2.5k
- PR merge metrics
- No merged PRs in 30d
Description
**Describe the bug**
If you use 'dayjs('-000001').year()', you can get the real '-1' year. But if you use the format method, the internal [padStart ](https://github.com/iamkun/dayjs/blob/dev/src/utils.js#L3)will automatically fill in 0. I'm not sure if this is a special scenario? Does it need special processing?
dayjs('-000001').format('YYYY')
// '00-1'
dayjs('-000010').format('YYYY')
// '0-10'
dayjs('-000100').format('YYYY')
// '-100'
**Expected behavior**
dayjs('-000001').format('YYYY')
// '-0001'
dayjs('-000010').format('YYYY')
// '-0010'
dayjs('-000100').format('YYYY')
// '-0100'
**Information**
- Day.js Version [e.g. v1.11.13]
- OS: [e.g. windows]
- Browser [e.g. chrome 128]
- Time zone: utc
Contributor guide
Research direction
Start with the linked src/utils.js padStart implementation, then trace how format('YYYY') uses it for negative years. Compare the current output with the examples in the issue and verify that the expected '-0001', '-0010', and '-0100' results are produced.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- javascript
- Domain
- tooling
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 45/100