Skip to content

Commit 399fb77

Browse files
author
avandras
committed
Use a backward-compatible way of aware timestamp
1 parent 00b0267 commit 399fb77

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

patroni/multisite.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
import time
55

66
from collections.abc import Callable
7-
from datetime import datetime
7+
from datetime import datetime, timezone
88
from threading import Event, Thread
99
from typing import Any, Dict, List, Optional, TYPE_CHECKING
1010

@@ -410,7 +410,7 @@ def __init__(self, crd_name: str, crd_uid: str, reporter: str, crd_api: str):
410410
def state_transition(self, new_state: str, note: str):
411411
self._status_update = {"status": {"Multisite": new_state}}
412412

413-
failover_time = datetime.utcnow().strftime("%Y-%m-%dT%H:%M:%S.%fZ")
413+
failover_time = datetime.now(timezone.utc).strftime("%Y-%m-%dT%H:%M:%S.%fZ")
414414
reason = 'Promote' if new_state == 'Leader' else 'Demote'
415415

416416
# TODO: check if this is needed, no current call comes without note (this is already reflected in the signature)

0 commit comments

Comments
 (0)