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 aware objects when storing and reading UTC timestamps #4017
Conversation
Hmm, the actual issue here is with how we create the timestamp - I don't think we can really solve that though, when we already have existing data, so I guess this might be needed middle ground 😐 |
This is not really the case though? My recommendation would be to stick to UTC stamps, and as explained, only deal with timezones when it's time (duh) to display it to the user. |
Well, not really. |
This is technically ready to go. Aware datetime objects are now used in places where they are (or can end up) being stored in the config, along with UTC conversion back. One thing I'd like to point out tho - the audio cog has lots of |
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.
A very late review, sorry for that.
Aside from review comments:
- The
message.created_at
inredbot/cogs/filter/filter.py:L376
was missed - Per your comment, I checked Audio's usage of
utcnow()
and it shouldn't need any changes, so this PR doesn't need to touch it.
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.
Looks good to me, thanks for contributing these fixes for the timezone madness 😄
Type
Description of the changes
.utcfromtimestamp()
takes local timezone into account when converting a timestamp back into adatetime
object: https://cdn.discordapp.com/attachments/160386989819035648/725707305320185876/unknown.pngConsidering that the timestamp that ends up being stored is in UTC, this is probably not what was intended.
Ref of where the value is stored:
Red-DiscordBot/redbot/cogs/mod/kickban.py
Line 445 in 6328403
There appears to be one other place where
.utcfromtimestamp()
is used - I modified that one accordingly too:Red-DiscordBot/redbot/core/bank.py
Line 136 in ad97918