From 23a5924e5d0393fbdc13a222dcf078f84b6f5395 Mon Sep 17 00:00:00 2001 From: Fang Lin Date: Thu, 22 Feb 2024 20:14:26 -0800 Subject: [PATCH] Rollback 9f5361b, notices only have date, should not add time --- uw_sws/notice.py | 6 ++---- uw_sws/tests/test_notice.py | 6 +++--- 2 files changed, 5 insertions(+), 7 deletions(-) diff --git a/uw_sws/notice.py b/uw_sws/notice.py index 3c68912..4e83882 100644 --- a/uw_sws/notice.py +++ b/uw_sws/notice.py @@ -6,7 +6,7 @@ for notice resource """ -from datetime import datetime, timezone +from datetime import timezone from dateutil import parser import logging from uw_sws.models import Notice, NoticeAttribute @@ -27,9 +27,7 @@ def get_notices_by_regid(regid): def _str_to_utc(date_str): date = parser.parse(date_str) - return datetime.combine( - date, datetime.min.time(), tzinfo=SWS_TIMEZONE).astimezone( - timezone.utc) + return SWS_TIMEZONE.localize(date).astimezone(timezone.utc) def _notices_from_json(notice_data): diff --git a/uw_sws/tests/test_notice.py b/uw_sws/tests/test_notice.py index ad1cd84..8ce94e7 100644 --- a/uw_sws/tests/test_notice.py +++ b/uw_sws/tests/test_notice.py @@ -11,9 +11,9 @@ def date_to_dtime(adate): - return datetime.combine( - adate, datetime.min.time(), tzinfo=SWS_TIMEZONE).astimezone( - timezone.utc).isoformat() + return SWS_TIMEZONE.localize( + datetime(year=adate.year, month=adate.month, day=adate.day) + ).astimezone(timezone.utc).isoformat() @fdao_pws_override