Skip to content

chore: replace deprecated datetime.utcnow() with timezone-aware datetime#2618

Merged
crivetimihai merged 1 commit intoIBM:mainfrom
jonathan-fulton:fix/deprecated-datetime-utcnow
Jan 31, 2026
Merged

chore: replace deprecated datetime.utcnow() with timezone-aware datetime#2618
crivetimihai merged 1 commit intoIBM:mainfrom
jonathan-fulton:fix/deprecated-datetime-utcnow

Conversation

@jonathan-fulton
Copy link
Copy Markdown
Contributor

Summary

Replace deprecated datetime.utcnow() with datetime.now(timezone.utc).

Problem

datetime.utcnow() is deprecated in Python 3.12 as it returns a naive datetime without timezone information, which can cause timezone-related bugs.

Solution

  • Added timezone to the import from datetime
  • Replaced datetime.utcnow() with datetime.now(timezone.utc)

This returns a timezone-aware datetime that properly handles UTC.

Fixes #2377

@jonathan-fulton jonathan-fulton force-pushed the fix/deprecated-datetime-utcnow branch from e9eb290 to ae9ca15 Compare January 31, 2026 18:39
@crivetimihai crivetimihai self-assigned this Jan 31, 2026
@crivetimihai crivetimihai added this to the Release 1.0.0-RC1 milestone Jan 31, 2026
@crivetimihai
Copy link
Copy Markdown
Member

Thanks @jonathan-fulton! Clean deprecation fix. Verified this is the only code usage of utcnow() in the codebase. The timezone-aware datetime is the correct approach for Python 3.12+. I'll start merging and rebasing.

datetime.utcnow() is deprecated in Python 3.12 and returns a naive datetime
without timezone info. Replace with datetime.now(timezone.utc) which returns
a timezone-aware datetime.

Fixes IBM#2377

Signed-off-by: Jonathan Fulton <jonathan@jonathanfulton.com>
@crivetimihai crivetimihai force-pushed the fix/deprecated-datetime-utcnow branch from ae9ca15 to e4b9280 Compare January 31, 2026 20:43
@crivetimihai crivetimihai merged commit 8dde40d into IBM:main Jan 31, 2026
51 checks passed
hughhennelly pushed a commit to hughhennelly/mcp-context-forge that referenced this pull request Feb 8, 2026
…ime (IBM#2618)

datetime.utcnow() is deprecated in Python 3.12 and returns a naive datetime
without timezone info. Replace with datetime.now(timezone.utc) which returns
a timezone-aware datetime.

Fixes IBM#2377

Signed-off-by: Jonathan Fulton <jonathan@jonathanfulton.com>
Signed-off-by: hughhennnelly <hughhennelly06@gmail.com>
kcostell06 pushed a commit to kcostell06/mcp-context-forge that referenced this pull request Feb 24, 2026
…ime (IBM#2618)

datetime.utcnow() is deprecated in Python 3.12 and returns a naive datetime
without timezone info. Replace with datetime.now(timezone.utc) which returns
a timezone-aware datetime.

Fixes IBM#2377

Signed-off-by: Jonathan Fulton <jonathan@jonathanfulton.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[CLEANUP][SONAR][LOW]: Deprecated datetime.utcnow() usage in main.py

2 participants