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

Issues with odd months when restricting to "day" precision #251

Closed
ddellspe opened this issue Jan 15, 2022 · 1 comment
Closed

Issues with odd months when restricting to "day" precision #251

ddellspe opened this issue Jan 15, 2022 · 1 comment

Comments

@ddellspe
Copy link

What did you do?

I'm trying to provide more precision than "months" when the timedelta is more than 1 month, but I'm finding some issues using precisedelta set to days with a format of %d as seen below. This all seems to stem from the use of 30.5 as a divisor for mod in precisedelta and how it and ngettext interact with floats vs. ints when it comes to pluralize and the display of the days itself. For what it's worth, the same thing happens at second precision with microseconds present, etc. It seems to be at the minimum_unit where this logic takes place.

What did you expect to happen?

>>> import humanize
>>> import datetime
>>> humanize.precisedelta(datetime.timedelta(days=31), minimum_unit="days", format="%d")
'1 month'
>>> 
>>> import humanize
>>> import datetime
>>> humanize.precisedelta(datetime.timedelta(days=32), minimum_unit="days", format="%d")
'1 month and 1 day'
>>>

What actually happened?

>>> import humanize
>>> import datetime
>>> humanize.precisedelta(datetime.timedelta(days=31), minimum_unit="days", format="%d")
'1 month and 0 days'
>>> 
>>> import humanize
>>> import datetime
>>> humanize.precisedelta(datetime.timedelta(days=32), minimum_unit="days", format="%d")
'1 month and 1 days'
>>>

What versions are you using?

  • OS: Windows, Ubuntu 20.04
  • Python: 3.8.7
  • Humanize: 3.13.1

Please include code that reproduces the issue (included in expected, actually happened above)

@hugovk
Copy link
Collaborator

hugovk commented May 3, 2022

🚀 Development has moved to https://github.com/python-humanize/humanize 🚀

Please open new issues at https://github.com/python-humanize/humanize/issues

Edit: -> python-humanize/humanize#14

@hugovk hugovk closed this as completed May 3, 2022
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

No branches or pull requests

2 participants