From ed9883e80029961472088252af4e85f748ab82a9 Mon Sep 17 00:00:00 2001 From: Tom Ritter Date: Thu, 8 Oct 2026 16:02:29 +0000 Subject: [PATCH] Use UTC for the commit date in bug titles, and say so Hosts report the upstream commit time differently: gitlab and codeberg give the committer's local time with an offset, github gives UTC, and googlesource gives UTC with no zone. We dropped the offset, so titles showed the committer's wall-clock time (libgbm's 02:59 UTC commit was titled 12:59). Convert to UTC and append "UTC" to the title. --- components/bugzilla.py | 2 +- components/utilities.py | 9 ++++++++- tests/bugzilla.py | 2 +- tests/mach_vendor.py | 12 ++++++++++++ 4 files changed, 22 insertions(+), 3 deletions(-) diff --git a/components/bugzilla.py b/components/bugzilla.py index 4cabd950..794599f1 100644 --- a/components/bugzilla.py +++ b/components/bugzilla.py @@ -11,7 +11,7 @@ class CommentTemplates: @staticmethod def UPDATE_SUMMARY(library, new_release_version, release_timestamp): - return "Update %s to new version %s from %s" % ( + return "Update %s to new version %s from %s UTC" % ( library.name, new_release_version, release_timestamp) @staticmethod diff --git a/components/utilities.py b/components/utilities.py index 860ee9dc..39536a8b 100644 --- a/components/utilities.py +++ b/components/utilities.py @@ -11,6 +11,7 @@ import functools import time +from datetime import timezone from dateutil.parser import parse RETRY_TIMES_OVERRIDE = None @@ -66,7 +67,13 @@ def raise_(e): def string_date_to_uniform_string_date(s): - return parse(s).strftime('%Y-%m-%d %H:%M:%S') + # Hosts report commit times with an offset (gitlab: "...+10:00"), as UTC + # ("...Z"), or with no zone at all (googlesource, which is UTC). Normalize + # them all to UTC so the result doesn't depend on the committer's timezone. + d = parse(s) + if d.tzinfo is not None: + d = d.astimezone(timezone.utc) + return d.strftime('%Y-%m-%d %H:%M:%S') def merge_dictionaries(a, b, ignored_dicts=[], ignored_keys=[]): diff --git a/tests/bugzilla.py b/tests/bugzilla.py index d4f74f0f..ab5387ec 100755 --- a/tests/bugzilla.py +++ b/tests/bugzilla.py @@ -43,7 +43,7 @@ def do_POST(self): 'product': 'Core', 'component': 'ImageLib', 'type': "enhancement", - 'summary': 'Update dav1d to new version V1 from 2020-08-21 15:13:49', + 'summary': 'Update dav1d to new version V1 from 2020-08-21 13:13:49 UTC', 'description': '', 'whiteboard': '[3pl-filed]' + task_id_whiteboard(), 'cc': ['tom@mozilla.com', 'jewilde@mozilla.com', 'additional@example.com'], diff --git a/tests/mach_vendor.py b/tests/mach_vendor.py index 3c014235..99da347a 100644 --- a/tests/mach_vendor.py +++ b/tests/mach_vendor.py @@ -45,6 +45,18 @@ def testISO8601Timestamp(self): self._check_for_update(REVISION + " 2026-09-09T17:56:48Z"), (REVISION, "2026-09-09 17:56:48")) + def testOffsetTimestampIsConvertedToUTC(self): + # gitlab and codeberg report the committer's local time with an offset; + # the uniform date must be UTC, not the committer's wall-clock time. + self.assertEqual( + self._check_for_update(REVISION + " 2026-09-25T12:59:00.000+10:00"), + (REVISION, "2026-09-25 02:59:00")) + + def testNegativeOffsetCrossesMidnight(self): + self.assertEqual( + self._check_for_update(REVISION + " 2026-09-17T22:36:18.000-04:00"), + (REVISION, "2026-09-18 02:36:18")) + def testNoUpdateAvailable(self): self.assertEqual(self._check_for_update(""), (None, None))