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
Move away from naive datetimes in entry fields, introduce pendulum #3758
Conversation
Gah. We are using datetimes for a lot of stuff that is actually just dates (mostly things like release dates.) Adding a timezone to something like that doesn't make a lot of sense, because we already don't know on what time that day the thing was released, and also don't know what timezone it was in. I'm tempted to make all these fields actual EDIT: Updated the plan for these in the OP. |
Ooh. My pendulum change went in, this might be back on the table when they make a release. |
Sweet :) |
72a761b
to
69375d8
Compare
for more information, see https://pre-commit.ci
I made some changes to how things worked a bit. Now all datetimes (and dates) that go into entry fields are made into CoercingDateTimes, which are Pendulum DateTimes, with the added property that they are allowed to compare between tz aware and naive datetimes. This is to make transitioning from our fully naive past to fully tz aware future as painless as possible. I also adjusted how that class works, so instead of making comparisons always be naive, it assumes the other datetime is in the same timezone (very similar effect, maybe identical?) |
The test failure is to do with using the git version in our deps atm. We will wait for a real release before merging. |
Okay. I think pendulum and this PR are in a state we could release this now. Just need to bump version and write some docs/warnings if we want to go with it. |
Motivation for changes:
Improve the experience when dealing with dates in templates and if plugin:
In a notification template (or for use in logging)
Torrent finished {{transmission_date_done.diff_for_humans()}}
would turn into something likeTorrent finished 2 months ago
Detailed changes:
now
andutcnow
in templates are timezone aware, but when compared to naive times they assume the naive times are in the same timezone as them. This both replicates the current naive behavior, but also allows the user to be explicit about timezones if they wish. e.g.some_anime_release_date > now.in_timezone('Asia/Tokyo')
To Do:
now
).