monty-python icon indicating copy to clipboard operation
monty-python copied to clipboard

fix: use aware datetimes everywhere

Open shiftinv opened this issue 2 years ago • 5 comments

Enables DTZ rules, which require the use of timezone-aware datetimes everywhere. Previously some of the displayed times would've only been correct if the bot runs in UTC, since disnake assumes all naive datetimes are local time.

shiftinv avatar Mar 29 '23 13:03 shiftinv

Welp, turns out this will only work on >=3.11. Earlier versions of fromisoformat don't actually parse iso8601-formatted strings, contrary to the name.

Alternatives include:

  • arrow.get(t).datetime (56.7us)
  • datetime.strptime(t, "%Y-%m-%dT%H:%M:%S%z") (8.1us)
    • note the %z instead of Z
  • dateutil.parser.isoparse (5.2us)
    • arrow already depends on dateutil, fwiw

shiftinv avatar Apr 03 '23 12:04 shiftinv

Welp, turns out this will only work on >=3.11. Earlier versions of fromisoformat don't actually parse iso8601-formatted strings, contrary to the name.

Alternatives include:

* `arrow.get(t).datetime` (56.7us)

* `datetime.strptime(t, "%Y-%m-%dT%H:%M:%S%z")` (8.1us)
  
  * note the `%z` instead of `Z`

* `dateutil.parser.isoparse` (5.2us)
  
  * arrow already depends on dateutil, fwiw

feel free to use striptime or dateutil.parser. I think I'm already using datetime.strptime in the majority of places.

onerandomusername avatar Apr 16 '23 05:04 onerandomusername

Fixed in https://github.com/onerandomusername/monty-python/pull/240/commits/38f73ddf768d48583b86b95e6f9c86461a384242.

shiftinv avatar Apr 17 '23 17:04 shiftinv

Could you please rebase with signed commits?

onerandomusername avatar May 04 '23 02:05 onerandomusername

Could you please rebase with signed commits?

Done.

shiftinv avatar May 04 '23 13:05 shiftinv