diff --git a/bid_sniper.py b/bid_sniper.py index 8461d72a..1f4cc828 100755 --- a/bid_sniper.py +++ b/bid_sniper.py @@ -92,6 +92,8 @@ def __init__(self, config: Dict, dry_run: bool = False) -> None: # if set, the default note to assign favorites that don't have a note self.default_note = self.config["bid_sniper"].get("favorite_default_note", None) + self.date_format = "%Y-%m-%dT%H:%M:%S" + # logging setup logging_conf = config.get("logging", dict()) self.logger = logging.getLogger("shopgoodwill_bid_sniper") @@ -398,11 +400,19 @@ async def main_loop(self) -> None: if item_id in self.scheduled_tasks: continue + # SGW has been including microseconds inconsistently, + # and one is liable to see '2025-04-29T23:00:17.45' in + # the same response as '2025-05-01T22:09:00' + end_time = favorite_info["endTime"] + date_format = self.date_format + if "." in end_time: + date_format += ".%f" + # so close but yet so far away from ISO-8601 # SGW simply trims the "PDT" (or PST?) off of the timestamps # TODO validate that the site only uses a single timezone! end_time = ( - datetime.datetime.fromisoformat(favorite_info["endTime"]) + datetime.datetime.strptime(end_time, date_format) .replace(tzinfo=ZoneInfo("US/Pacific")) .astimezone(ZoneInfo("Etc/UTC")) )