Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit 9808b07

Browse files
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月14日T15:40:25.013414,98.73417721518987 # With .now(datetime.timezone.utc) Time,Idle 2025年05月14日T15: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‎

Lines changed: 1 addition & 1 deletion
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)

AltStyle によって変換されたページ (->オリジナル) /