-
-
Notifications
You must be signed in to change notification settings - Fork 691
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
Correct error in humanize() granularities for single seconds #748
Conversation
Codecov Report
@@ Coverage Diff @@
## master #748 +/- ##
=====================================
Coverage 100% 100%
=====================================
Files 9 9
Lines 1667 1669 +2
Branches 281 282 +1
=====================================
+ Hits 1667 1669 +2
Continue to review full report at Codecov.
|
@jadchaar both bugs look fixed now. (arrow) chris@ThinkPad:~/arrow$ python
Python 3.7.4 (default, Sep 19 2019, 11:01:37)
[GCC 5.4.0 20160609] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import arrow
>>> now=arrow.utcnow()
>>> mins=now.shift(seconds=-200)
>>> mins.humanize(now, only_distance=True)
'3 minutes'
>>> mins.humanize(now, only_distance=True, granularity="second")
'200 seconds'
>>> mins.humanize(now, granularity="second")
'200 seconds ago' (arrow) chris@ThinkPad:~/arrow$ python
Python 3.7.4 (default, Sep 19 2019, 11:01:37)
[GCC 5.4.0 20160609] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import arrow
>>> now=arrow.utcnow()
>>> mins=now.shift(seconds=-200)
>>> mins.humanize(now, only_distance=True)
'3 minutes'
>>> mins.humanize(now, only_distance=True, granularity="second")
'200 seconds'
>>> mins.humanize(now, granularity="second")
'200 seconds ago'
>>> import datetime, arrow
>>> yesterday = datetime.datetime.now()-datetime.timedelta(1)
>>> yesterday_date = yesterday.date()
>>> arrow.get(yesterday_date).humanize()
'a day ago' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Solid PR, I can't believe the seconds thing was missed for so long.
@@ -2793,6 +2825,7 @@ class CzechLocale(Locale): | |||
|
|||
timeframes = { | |||
"now": "Teď", | |||
"second": {"past": "vteřina", "future": "vteřina", "zero": "vteřina"}, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We can rely on others to correct these kinds of locales.
elif diff < 129600: | ||
# anything less than 48 hours should be 1 day | ||
elif diff < 172800: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🚀
Pull Request Checklist
Thank you for taking the time to improve Arrow! Before submitting your pull request, please check all appropriate boxes:
tox
ormake test
to find out!).master
branch.If you have any questions about your code changes or any of the points above, please submit your questions along with the pull request and we will try our best to help!
Description of Changes
Replaces: #726
Closes: #727
Closes: #697