diff --git a/components/bugzilla.py b/components/bugzilla.py index 4cabd95..794599f 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 860ee9d..39536a8 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 d4f74f0..ab5387e 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 3c01423..99da347 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))