Skip to content

refactor(health): replace deprecated datetime.utcnow() with timezone-aware datetime#1056

Merged
canihavesomecoffee merged 4 commits intoCCExtractor:masterfrom
MrButtCode:fix/datetime-deprecation
Mar 19, 2026
Merged

refactor(health): replace deprecated datetime.utcnow() with timezone-aware datetime#1056
canihavesomecoffee merged 4 commits intoCCExtractor:masterfrom
MrButtCode:fix/datetime-deprecation

Conversation

@MrButtCode
Copy link

@MrButtCode MrButtCode commented Mar 8, 2026

Resolves multiple DeprecationWarnings in mod_health/controllers.py caused by the use of datetime.utcnow().

Python 3.12 formally deprecated datetime.utcnow() in favor of timezone-aware objects. To harden the health module for newer Python runtimes while preserving the exact JSON API contract for existing consumers, I migrated the calls to datetime.now(timezone.utc).

By using a proper timezone aware object the native isoformat() method automatically handles the UTC offset perfectly. This ensures flawless backward compatability with the current frontend consumers while satisfying the new Python 3.12 requirements without needing any manual string concatenation.

@canihavesomecoffee canihavesomecoffee force-pushed the fix/datetime-deprecation branch 2 times, most recently from a02956e to f4b62ba Compare March 15, 2026 09:21
@canihavesomecoffee canihavesomecoffee force-pushed the fix/datetime-deprecation branch from 33fd30b to 3041c62 Compare March 19, 2026 09:04
@sonarqubecloud
Copy link

@canihavesomecoffee canihavesomecoffee merged commit 0e32aed into CCExtractor:master Mar 19, 2026
6 checks passed
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.

2 participants