Skip to content

Commit da98e34

Browse files
MrButtCodecanihavesomecoffee
authored andcommitted
refactor(health): replace deprecated datetime.utcnow() with timezone-aware datetime
1 parent c6ba18d commit da98e34

1 file changed

Lines changed: 4 additions & 4 deletions

File tree

mod_health/controllers.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
import os
44
import subprocess
5-
from datetime import datetime
5+
from datetime import datetime, timezone
66
from typing import Any, Dict, Optional, Tuple
77

88
from flask import Blueprint, current_app, jsonify
@@ -79,7 +79,7 @@ def health_check() -> Tuple[Any, int]:
7979

8080
checks: Dict[str, Any] = {
8181
'status': 'healthy' if all_healthy else 'unhealthy',
82-
'timestamp': datetime.utcnow().isoformat() + 'Z',
82+
'timestamp': datetime.now(timezone.utc).replace(tzinfo=None).isoformat() + 'Z',
8383
'checks': check_results
8484
}
8585

@@ -99,7 +99,7 @@ def liveness_check() -> Tuple[Any, int]:
9999
"""
100100
return jsonify({
101101
'status': 'alive',
102-
'timestamp': datetime.utcnow().isoformat() + 'Z'
102+
'timestamp': datetime.now(timezone.utc).replace(tzinfo=None).isoformat() + 'Z'
103103
}), 200
104104

105105

@@ -172,7 +172,7 @@ def version_check() -> Tuple[Any, int]:
172172
git_info = get_git_info()
173173

174174
response = {
175-
'timestamp': datetime.utcnow().isoformat() + 'Z',
175+
'timestamp': datetime.now(timezone.utc).replace(tzinfo=None).isoformat() + 'Z',
176176
'git': git_info,
177177
}
178178

0 commit comments

Comments
 (0)