mirror of
https://github.com/zulip/zulip.git
synced 2025-11-02 04:53:36 +00:00
ruff: Fix DTZ001 datetime.datetime() without tzinfo argument.
Signed-off-by: Anders Kaseorg <anders@zulip.com>
This commit is contained in:
committed by
Tim Abbott
parent
1451dbffb9
commit
7216ba4813
@@ -30,7 +30,6 @@ from scripts.lib.zulip_tools import overwrite_symlink
|
||||
from zerver.lib.avatar_hash import user_avatar_path_from_ids
|
||||
from zerver.lib.pysa import mark_sanitized
|
||||
from zerver.lib.upload import get_bucket
|
||||
from zerver.lib.utils import assert_is_not_none
|
||||
from zerver.models import (
|
||||
AlertWord,
|
||||
Attachment,
|
||||
@@ -434,8 +433,7 @@ def floatify_datetime_fields(data: TableData, table: TableName) -> None:
|
||||
continue
|
||||
assert isinstance(dt, datetime.datetime)
|
||||
assert not timezone_is_naive(dt)
|
||||
utc_naive = dt.replace(tzinfo=None) - assert_is_not_none(dt.utcoffset())
|
||||
item[field] = (utc_naive - datetime.datetime(1970, 1, 1)).total_seconds()
|
||||
item[field] = dt.timestamp()
|
||||
|
||||
|
||||
def listify_bithandler_fields(data: TableData, table: TableName) -> None:
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import sys
|
||||
from datetime import datetime
|
||||
from datetime import datetime, timezone
|
||||
|
||||
from django.utils.timezone import now as timezone_now
|
||||
|
||||
@@ -35,7 +35,10 @@ class TimeZoneTest(ZulipTestCase):
|
||||
assert not missing, missing
|
||||
|
||||
now = timezone_now()
|
||||
dates = [datetime(now.year, 6, 21), datetime(now.year, 12, 21)]
|
||||
dates = [
|
||||
datetime(now.year, 6, 21, tzinfo=timezone.utc),
|
||||
datetime(now.year, 12, 21, tzinfo=timezone.utc),
|
||||
]
|
||||
extra = {*common_timezones.items(), *ambiguous_abbrevs}
|
||||
for name in zoneinfo.available_timezones():
|
||||
tz = zoneinfo.ZoneInfo(name)
|
||||
|
||||
Reference in New Issue
Block a user