From d0a5ab1c6d87c90183098190f1b9a59986b2afa4 Mon Sep 17 00:00:00 2001 From: Timo Wilken Date: Wed, 29 Nov 2023 14:09:59 +0100 Subject: [PATCH] Fix datetime logic --- list-branch-pr | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/list-branch-pr b/list-branch-pr index e5ad530b..6a5c6c5d 100755 --- a/list-branch-pr +++ b/list-branch-pr @@ -24,7 +24,7 @@ import sys from argparse import ArgumentParser from collections import defaultdict -from datetime import datetime +from datetime import datetime, timezone from gql import Client, gql from gql.transport.requests import RequestsHTTPTransport @@ -258,11 +258,11 @@ def main(args): # pr["updated_at"] can apparently be None sometimes, which breaks # sorting, so default to the empty string if so. for pull in sorted(prs, key=lambda pr: pr["updated_at"] or ""): - last_push_timestamp = \ - int(datetime.fromisoformat(pull["updated_at"]).timestamp) \ - if pull["updated_at"] else int(datetime.utcnow().timestamp) + updated_at = pull["updated_at"] + last_push = datetime.fromisoformat(updated_at) \ + if updated_at else datetime.now(timezone.utc) print(group, pull["number"], pull["sha"], pull["build_config"], - last_push_timestamp, sep="\t") + int(last_push.timestamp()), sep="\t") if grouped["untested"]: # If there are untested PRs waiting, build all of them first.