webchanges
webchanges copied to clipboard
[FEATURE] Support human-readable dates for database rollbacks
Is your feature request related to a problem? Please describe.
--rollback-database
uses Unix timestamps, which can be inconvenient to obtain and are hard to comprehend for humans.
Describe the solution you'd like.
--rollback-database
could support human-readable dates (e.g. in ISO format):
>>> import datetime
>>> d = datetime.datetime.fromisoformat('2024-04-23T14:26:40+02:00')
>>> d.replace(tzinfo=datetime.timezone.utc).timestamp()
Or using dateutil
(examples):
>>> from dateutil import parser
>>> d = parser.parse('2024-04-23T14:39:38 CEST')
>>> d.replace(tzinfo=datetime.timezone.utc).timestamp()
dateutil
accepts many inputs and is already installed as a dependency on my system for several applications. However, I am skeptical that an additional dependency is warranted considering how rarely most users will roll back their database. I would be happy with just datetime.datetime.fromisoformat
.
In short:
--rollback-database ISO_DATE
--rollback-database TIMESTAMP
Makes sense, thanks for taking the time to make the suggestion!
Can structure it so that dateutil
is used unless it's not found on the system, in which case it it falls back to using datetime
(so there's no formal dependency on dateutil
.
@Markus00000 I just implemented a stealth version of this in v3.24, just released, but had no time for unit testing or documentation. Can you give it a try and see if it works for you?
Date only, time only, date and time… everything was parsed as expected. So much more convenient than timestamps.
Showing the exact roll back date before rolling back is excellent, too.
Well done!
Thanks, and thanks for testing. Officially rolled out in v3.24.1.