diff --git a/git_config.py b/git_config.py index 8c2eb6e9..c19f7662 100644 --- a/git_config.py +++ b/git_config.py @@ -795,8 +795,8 @@ class SyncAnalysisState: to be logged. """ self._config = config - now = datetime.datetime.utcnow() - self._Set("main.synctime", now.isoformat(timespec="microseconds") + "Z") + now = datetime.datetime.now(datetime.timezone.utc) + self._Set("main.synctime", now.isoformat(timespec="microseconds")) self._Set("main.version", "1") self._Set("sys.argv", sys.argv) for key, value in superproject_logging_data.items(): diff --git a/git_trace2_event_log_base.py b/git_trace2_event_log_base.py index a111668a..d986b240 100644 --- a/git_trace2_event_log_base.py +++ b/git_trace2_event_log_base.py @@ -71,7 +71,7 @@ class BaseEventLog(object): if env is None: env = os.environ - self.start = datetime.datetime.utcnow() + self.start = datetime.datetime.now(datetime.timezone.utc) # Save both our sid component and the complete sid. # We use our sid component (self._sid) as the unique filename prefix and @@ -126,7 +126,7 @@ class BaseEventLog(object): "event": event_name, "sid": self._full_sid, "thread": threading.current_thread().name, - "time": datetime.datetime.utcnow().isoformat() + "Z", + "time": datetime.datetime.now(datetime.timezone.utc).isoformat(), } def StartEvent(self): @@ -147,7 +147,7 @@ class BaseEventLog(object): if result is None: result = 0 exit_event["code"] = result - time_delta = datetime.datetime.utcnow() - self.start + time_delta = datetime.datetime.now(datetime.timezone.utc) - self.start exit_event["t_abs"] = time_delta.total_seconds() self._log.append(exit_event) diff --git a/repo b/repo index d2a4df2e..7f24ff1e 100755 --- a/repo +++ b/repo @@ -173,7 +173,7 @@ if not REPO_REV: BUG_URL = "https://issues.gerritcodereview.com/issues/new?component=1370071" # increment this whenever we make important changes to this script -VERSION = (2, 36) +VERSION = (2, 37) # increment this if the MAINTAINER_KEYS block is modified KEYRING_VERSION = (2, 3) @@ -838,7 +838,7 @@ def SetGitTrace2ParentSid(env=None): KEY = "GIT_TRACE2_PARENT_SID" - now = datetime.datetime.utcnow() + now = datetime.datetime.now(datetime.timezone.utc) value = "repo-%s-P%08x" % (now.strftime("%Y%m%dT%H%M%SZ"), os.getpid()) # If it's already set, then append ourselves. diff --git a/tests/test_git_superproject.py b/tests/test_git_superproject.py index dc46ec65..600b069f 100644 --- a/tests/test_git_superproject.py +++ b/tests/test_git_superproject.py @@ -108,7 +108,9 @@ class SuperprojectTestCase(unittest.TestCase): self.assertRegex(log_entry["sid"], self.FULL_SID_REGEX) else: self.assertRegex(log_entry["sid"], self.SELF_SID_REGEX) - self.assertRegex(log_entry["time"], r"^\d+-\d+-\d+T\d+:\d+:\d+\.\d+Z$") + self.assertRegex( + log_entry["time"], r"^\d+-\d+-\d+T\d+:\d+:\d+\.\d+\+00:00$" + ) def readLog(self, log_path): """Helper function to read log data into a list.""" diff --git a/tests/test_git_trace2_event_log.py b/tests/test_git_trace2_event_log.py index 9d4f24c3..d8e963dd 100644 --- a/tests/test_git_trace2_event_log.py +++ b/tests/test_git_trace2_event_log.py @@ -90,7 +90,9 @@ class EventLogTestCase(unittest.TestCase): self.assertRegex(log_entry["sid"], self.FULL_SID_REGEX) else: self.assertRegex(log_entry["sid"], self.SELF_SID_REGEX) - self.assertRegex(log_entry["time"], r"^\d+-\d+-\d+T\d+:\d+:\d+\.\d+Z$") + self.assertRegex( + log_entry["time"], r"^\d+-\d+-\d+T\d+:\d+:\d+\.\d+\+00:00$" + ) def readLog(self, log_path): """Helper function to read log data into a list."""