From d13a014bab287c9038ed2148faa5f32602aea194 Mon Sep 17 00:00:00 2001 From: Mike Lang Date: Thu, 26 Oct 2023 12:15:12 +1100 Subject: [PATCH] schedulebot: Accept start timestamp with a trailing Z --- zulip_bots/zulip_bots/schedulebot.py | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/zulip_bots/zulip_bots/schedulebot.py b/zulip_bots/zulip_bots/schedulebot.py index d70f9a8..d5472b4 100644 --- a/zulip_bots/zulip_bots/schedulebot.py +++ b/zulip_bots/zulip_bots/schedulebot.py @@ -225,9 +225,15 @@ def main(conf_file, hour=-1, no_groups=False, stream="General", no_mentions=Fals send_auth = config.get("send_user", config["api_user"]) send_client = Client(config["url"], send_auth["email"], send_auth["api_key"]) group_ids = config["groups"] - start_time = timegm(time.strptime(config["start_time"], "%Y-%m-%dT%H:%M:%S")) schedule = parse_schedule(config["members"], config["schedule"]) groups_by_shift = {int(id): shifts for id, shifts in config["groups_by_shift"].items()} + + # Accept start time timestamp with or without trailing "Z" indicating UTC. + start_time = config["start_time"] + if start_time.endswith("Z"): + start_time = start_time[:-1] + start_time = timegm(time.strptime(start_time, "%Y-%m-%dT%H:%M:%S")) + if hour >= 0: if not no_groups: update_groups(client, group_ids, groups_by_shift, schedule, hour, start_time, last)