Twentysix26 / x26-Cogs

General purpose cogs for Red V3
GNU General Public License v3.0
41 stars 30 forks source link

[Defender] Ensure timestamps are in UTC #49

Closed Injabie3 closed 2 years ago

Injabie3 commented 2 years ago

This PR fixes non-timezone aware timestamps. In dpy 1.x, timestamps are not timezone aware. When we convert the timestamp to a Discord timestamp, the timestamp is in the local timezone, but Discord expects it in UTC. We should convert the time object to UTC first, and then convert it to a UNIX timestamp.

In dpy 2.x, timestamps from discord objects are now timezone aware, so this should be a no-op (that being said, I have not tried with dpy2 yet).

I replaced the datetime arg with ts instead in order to avoid collision with the datetime module while accessing timezone.

Before (my timezone is GMT-7 Pacific): Screenshot from 2022-05-08 23-43-03

After: Screenshot from 2022-05-08 23-37-59

Twentysix26 commented 2 years ago

Ty!