Skip to content

Commit

Permalink
fix behave
Browse files Browse the repository at this point in the history
  • Loading branch information
petrjasek committed Dec 11, 2024
1 parent f633f1c commit f2b181d
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions server/planning/events/events.py
Original file line number Diff line number Diff line change
Expand Up @@ -365,11 +365,11 @@ def _validate_dates(self, updates, original=None):
raise SuperdeskApiError(message="Event START DATE and END DATE are mandatory.")

if (
dates.get("no_end_time") == True
dates.get("no_end_time") is True
and end_date.date() < get_local_date(dates.get("start"), dates.get("tz")).date()
):
raise SuperdeskApiError(message="END TIME should be after START TIME")
elif dates.get("no_end_time") != True and end_date < start_date:
elif dates.get("no_end_time") is not True and end_date < start_date:
raise SuperdeskApiError(message="END TIME should be after START TIME")

if (
Expand Down Expand Up @@ -1040,4 +1040,7 @@ def set_planning_schedule(event):


def get_local_date(date: datetime, tz: str) -> datetime:
return date.astimezone(pytz.timezone(tz))
try:
return date.astimezone(pytz.timezone(tz))
except pytz.exceptions.UnknownTimeZoneError:
return date

0 comments on commit f2b181d

Please sign in to comment.