Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: duration.minutes() should guaranteed to be in [0, 60) #2338

Open
wants to merge 5 commits into
base: dev
Choose a base branch
from

Conversation

KronosDev-Pro
Copy link

fix #2329

@codecov
Copy link

codecov bot commented Jun 22, 2023

Codecov Report

Patch coverage: 100.00% and no project coverage change.

Comparison is base (a4ff1d2) 100.00% compared to head (9019ba7) 100.00%.

❗ Current head 9019ba7 differs from pull request most recent head 0d86dd6. Consider uploading reports for the commit 0d86dd6 to get more accurate results

Additional details and impacted files
@@            Coverage Diff             @@
##               dev     #2338    +/-   ##
==========================================
  Coverage   100.00%   100.00%            
==========================================
  Files          183       183            
  Lines         2249      2142   -107     
  Branches       636       566    -70     
==========================================
- Hits          2249      2142   -107     
Files Changed Coverage Δ
src/plugin/duration/index.js 100.00% <100.00%> (ø)

... and 4 files with indirect coverage changes

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@iamkun iamkun changed the title fix issue #2329 fix: duration.minutes() should guaranteed to be in [0, 60) Jun 23, 2023
@iamkun
Copy link
Owner

iamkun commented Jun 23, 2023

after careful thought, the main issue leading to this bug is not related to the display get getter, but the setter and the constructor.

dayjs.duration({ minutes: 359 }).toJSON() should return "PT5H59M" rather than ""PT359M""

that is to say, you can try to move your calc logic to https://github.com/iamkun/dayjs/blob/dev/src/plugin/duration/index.js#L78

that will make the getter and setter both correct.

ps: IMHO, you have made a nice refactor to the test cases. However, it will be better to keep all the existing test cases to make the lib stronger. Any new PRs should only add new cases or modify the error cases. 😀

@iamkun
Copy link
Owner

iamkun commented Sep 19, 2023

after checking the PR again, still I think, we should update the input part (setter and the constructor) to make the inner data correct, not in the output part

What do you think then?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

duration.minutes() not guaranteed to be in [0, 60)
3 participants