Skip to content

Commit 9808b07

Browse files
authored
Rollup merge of #141009 - emmanuel-ferdman:master, r=marcoieni
Migrate to modern datetime API # PR Summary This small PR resolves the `datetime` library warnings: ```python DeprecationWarning: datetime.datetime.utcnow() is deprecated and scheduled for removal in a future version. Use timezone-aware objects to represent datetimes in UTC: datetime.datetime.now(datetime.UTC). or datetime.datetime.utcnow() ``` Note that `.replace(tzinfo=None)` allows to keep the original behavior where the time appears as a naive UTC timestamp (i.e., without any timezone offset). Comparision: ```python # With .utcnow() or .now(datetime.timezone.utc).replace(tzinfo=None) Time,Idle 2025-05-14T15:40:25.013414,98.73417721518987 # With .now(datetime.timezone.utc) Time,Idle 2025-05-14T15:40:25.013414+00:00,98.73417721518987 ```
2 parents e53b9f8 + 754b06f commit 9808b07

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

src/ci/cpu-usage-over-time.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -170,7 +170,7 @@ def idle_since(self, prev):
170170
while True:
171171
time.sleep(1)
172172
next_state = State()
173-
now = datetime.datetime.utcnow().isoformat()
173+
now = datetime.datetime.now(datetime.timezone.utc).replace(tzinfo=None).isoformat()
174174
idle = next_state.idle_since(cur_state)
175175
print("%s,%s" % (now, idle))
176176
sys.stdout.flush()

0 commit comments

Comments
 (0)