-
Notifications
You must be signed in to change notification settings - Fork 10
Conversation
Reference to missing documentation file removed.
As you commented in another communication. CryptoJWT 1.6.0 is indeed on PyPI. |
fixed here we just have to squash before merging |
@@ -200,7 +202,8 @@ def time_a_while_ago( | |||
:return: datetime instance using UTC time | |||
""" | |||
delta = timedelta(days, seconds, microseconds, milliseconds, minutes, hours, weeks) | |||
return datetime.utcnow() - delta | |||
res = datetime.now(timezone.utc) - delta | |||
return res.replace(tzinfo=None) |
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.
why do we need to strip the timezone information?
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.
naive and aware datetime can't be compared, so for retrocompatibility I operate with aware datetime but always return naive datetime
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.
considering that standard requries utc datetime, it's not important to have it with 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.
What are those comparisons?
It is important it to have it with timezone to ensure that operations on time are done in the needed timezone.
I would argue we need to do the opposite - have all datetimes in UTC to ensure calculations are correct. So, the comparisons that take place, should also have dates loaded as UTC.
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.
the comparison doesn't happen here but later in a unit test
______________________________________________________________________________________________ test_time_a_while_ago _______________________________________________________________________________________________
def test_time_a_while_ago():
dt = datetime.utcnow()
t = time_a_while_ago(seconds=10)
> delta = dt - t # slightly less than 10
E TypeError: can't subtract offset-naive and offset-aware datetimes
tests/test_03_time_util.py:204: TypeError
considering that standard require UTC timestamp I didn't see any needs to carrying aware datetimes in the code BUT you kow that I'ma good boy that can spend some more effort to get all happy :)
Roland approved, do we have to put another change or do you think that's good enough as is?
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.
If we are going to change .utcnow()
to .now(utc)
I think we should do it everywhere.
If we don't want to do it, then let's not do it at all.
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.
I don't know the conseguences to other libraries and behaviours
I preferred to let the type be the same as before to prevent any breaking changes with this release
that's the answer, feel free to open an issue to keep track of this
@rohe @c00kiemon5ter can we merge this as it is or do I have to return a tz aware datetime and fix the unit test as well? |
go forward! |
Absolutely, merge it ! |
Ok guys, just to tell that the only other place where utcnow is used is here
and that's just to get the TZINFO from the host |
this PR fixed the datetime utcnow timestamp that still returned a non utc timestamp