iamkun / iamkun/dayjs

duration humanize ignoring leap years

Open
#3,170 0 comments 0 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**
I called `dayjs.duration("P9999Y").humanize()` and was returned `9992 years`
If I call `dayjs.duration("P9999Y").asYears()` then I get 9999.

**Expected behavior**
Expected that on large durations then `humanize` returns the same number of years as `.asYears()`.

**Information**
- Day.js Version: v1.11.21
- OS: Mac OS
- Browser: Brave v1.93.132
- Time zone: BST

Contributor guide

Open the contributing guide

Research direction

Start by reproducing the `dayjs.duration("P9999Y").humanize()` and `.asYears()` examples in the duration API. Trace how `humanize` converts large year values and handles leap years, then add regression coverage showing that the humanized result matches the duration's year value. Done means the reported case returns 9999 years without changing expected behavior for other durations.

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
Quiet
Clarity
Mostly clear
Newbie friendliness
55/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.