Browse Source

Fixed condition to only add shifts not already added

master
Raphael Roberts 5 years ago
parent
commit
0cbfe57813
  1. 9
      panera_shifts_gcal_backend/__init__.py

9
panera_shifts_gcal_backend/__init__.py

@ -20,7 +20,9 @@ def input_all_shifts_for_month():
max_day = cal_module.monthrange(today.year, today.month)
start = datetime.date(today.year, today.month, 1)
end = datetime.date(today.year, today.month, max_day[1])
read_from = datetime.date(start.year, start.month, start.day)
read_from = datetime.datetime.combine(
start, datetime.time(0, 0, 0, 0), datetime.timezone.utc
)
start_dt = datetime.datetime.combine(
start, datetime.time(0, 0, 0, 0), datetime.timezone.utc
)
@ -44,8 +46,9 @@ def input_all_shifts_for_month():
cafe_info = shifts_info["data"]["currentShifts"]["cafe"][0]
for shift in shifts_info["data"]["currentShifts"]["shifts"]:
s = Shift.from_dict(shift, cafe_info, timezone)
e = s.to_Event()
calendar.update_or_add_event(e)
if s.start > read_from:
e = s.to_Event()
calendar.update_or_add_event(e)
if __name__ == "__main__":

Loading…
Cancel
Save