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

Use humanize.intcomma to format years in time module #246

Merged
merged 2 commits into from Dec 13, 2021
Merged

Use humanize.intcomma to format years in time module #246

merged 2 commits into from Dec 13, 2021

Conversation

carterbox
Copy link
Contributor

Related to #245

Presently, it is hard to read very long times because the largest time denomination that humanize includes is years. In this pull request, humanize.intcomma() is now used to format the number of years returned by naturaldelta() and precisedelta().

Alternate approaches considered include:

  1. Adding a millennia denomination, but this would require all translations to be updated.
  2. Using the {:n} format specifier along with the standard locale module, but locale has inconsistent behavior across platforms and humanize already uses an internal localization module.

@codecov-commenter
Copy link

codecov-commenter commented Dec 5, 2021

Codecov Report

Merging #246 (d1faf1c) into master (429e3d8) will increase coverage by 0.02%.
The diff coverage is 100.00%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master     #246      +/-   ##
==========================================
+ Coverage   97.08%   97.10%   +0.02%     
==========================================
  Files          10       10              
  Lines         685      690       +5     
==========================================
+ Hits          665      670       +5     
  Misses         20       20              
Flag Coverage Δ
GHA_Ubuntu 95.94% <100.00%> (+0.02%) ⬆️
GHA_Windows 95.65% <100.00%> (+0.03%) ⬆️
GHA_macOS 95.94% <100.00%> (+0.02%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

Impacted Files Coverage Δ
src/humanize/time.py 96.46% <100.00%> (+0.08%) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 429e3d8...d1faf1c. Read the comment docs.

@hugovk
Copy link
Collaborator

hugovk commented Dec 12, 2021

Please could you add tests?

@carterbox
Copy link
Contributor Author

Yes. Added.

@hugovk hugovk added the changelog: Changed For changes in existing functionality label Dec 13, 2021
@hugovk hugovk changed the title NEW: Use humanize.intcomma to format years in time module Use humanize.intcomma to format years in time module Dec 13, 2021
@hugovk hugovk merged commit 49f2cd1 into jmoiron:master Dec 13, 2021
@hugovk
Copy link
Collaborator

hugovk commented Dec 13, 2021

Thanks!

@carterbox carterbox deleted the intcomma-years branch December 13, 2021 20:59
@hugovk hugovk changed the title Use humanize.intcomma to format years in time module Use humanize.intcomma to format years in time module Jan 30, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
changelog: Changed For changes in existing functionality
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants