Skip to content

Commit

Permalink
Rollback 9f5361b, notices only have date, should not add time
Browse files Browse the repository at this point in the history
  • Loading branch information
fanglinfang committed Feb 23, 2024
1 parent 9fcdb3c commit 23a5924
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 7 deletions.
6 changes: 2 additions & 4 deletions uw_sws/notice.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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):
Expand Down
6 changes: 3 additions & 3 deletions uw_sws/tests/test_notice.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 23a5924

Please # to comment.