-
Notifications
You must be signed in to change notification settings - Fork 148
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
Allow custom "now" in naturaldelta and naturaltime #144
Conversation
Codecov Report
@@ Coverage Diff @@
## master #144 +/- ##
=========================================
Coverage 100.00% 100.00%
=========================================
Files 9 9
Lines 560 569 +9
=========================================
+ Hits 560 569 +9
Flags with carried forward coverage won't be shown. Click here to find out more.
Continue to review full report at Codecov.
|
So... yeah, |
Thank you for the PR! So For example
Yeah, it's a bit annoying, I think psf/black#1288 is the issue for that. |
Thank you for your feedback :) Date, time and timezones are confusing.
Calling it My use case for this is as follows: I have a pair of >>> (
f"starting_time is {naturalday(starting_time)}, "
f"which was {naturaltime(starting_time, when=current_time)}"
)
"starting_time is Jul 12, which was 10 days ago" Usually it would make sense to just use |
I was about to update this PR (finally), but it seems like I have borked some tests. Well, lets see what's wrong. |
Huh... so it seems like I will squash all these fixup commits before merging. |
Ping me when you're ready for re-review :) |
This allows having a different point in time to which a value is compared. Useful if one is dealing with datetimes that are not in the local timezone.
Ping! @hugovk |
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.
Thank you! Just a little docstring nit.
src/humanize/time.py
Outdated
Examples | ||
Compare two timestamps in a custom local timezone:: | ||
|
||
from datetime import datetime, timedelta, timezone |
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.
Please can you change this example to use import datetime as dt
and dt.datetime
etc?
Rationale: https://adamj.eu/tech/2019/09/12/how-i-import-pythons-datetime-module/
Thank you! |
This allows having a different point in time to which a value is compared.
Useful if one is dealing with datetimes that are not in the local timezone.
Fixes #55.
Changes proposed in this pull request:
naturaldelta
andnaturaltime
now expose an optionalnow
parameterdatetime
objects that are not in the local timezone