mirror of
https://gitlab.archlinux.org/archlinux/aurweb.git
synced 2025-02-03 10:43:03 +01:00
housekeep: centralize datetime generation
Signed-off-by: Kevin Morris <kevr@0cost.org>
This commit is contained in:
parent
7bcc8d7ce7
commit
7f6c23d4cb
41 changed files with 146 additions and 179 deletions
|
@ -1,17 +1,17 @@
|
|||
from datetime import datetime
|
||||
from zoneinfo import ZoneInfo
|
||||
|
||||
from aurweb import filters
|
||||
from aurweb import filters, time
|
||||
|
||||
|
||||
def test_timestamp_to_datetime():
|
||||
ts = datetime.utcnow().timestamp()
|
||||
ts = time.utcnow()
|
||||
dt = datetime.utcfromtimestamp(int(ts))
|
||||
assert filters.timestamp_to_datetime(ts) == dt
|
||||
|
||||
|
||||
def test_as_timezone():
|
||||
ts = datetime.utcnow().timestamp()
|
||||
ts = time.utcnow()
|
||||
dt = filters.timestamp_to_datetime(ts)
|
||||
assert filters.as_timezone(dt, "UTC") == dt.astimezone(tz=ZoneInfo("UTC"))
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue