Skip to content

Commit b72fe05

Browse files
Merge pull request #1048 from Rajandeep98/Smartboard_Tz
smartboard timezone fix
2 parents 2be8b97 + e11c6ac commit b72fe05

File tree

1 file changed

+12
-2
lines changed

1 file changed

+12
-2
lines changed

api/app/resources/bookings/walkin/walkin.py

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -163,8 +163,18 @@ def get_all_app_from_agenda_panel(self, citizen=False, office=False):
163163
if office_id:
164164
past_hour = datetime.now(timezone.utc) - timedelta(minutes=15)
165165
future_hour = datetime.now(timezone.utc) + timedelta(minutes=15)
166-
local_past = pytz.utc.localize(past_hour)
167-
local_future = pytz.utc.localize(future_hour)
166+
if past_hour.tzinfo is None:
167+
# If it's naive, localize to UTC
168+
local_past = pytz.utc.localize(past_hour)
169+
else:
170+
# If it's already timezone-aware, no need to localize
171+
local_past = past_hour
172+
if future_hour.tzinfo is None:
173+
# Only localize if the datetime is naive
174+
local_future = pytz.utc.localize(future_hour)
175+
else:
176+
# If it's already timezone-aware, no need to localize
177+
local_future = future_hour
168178
# getting agenda panel app
169179
appointments = Appointment.query.filter_by(office_id=office_id)\
170180
.filter(Appointment.start_time <= local_future)\

0 commit comments

Comments
 (0)