From 0c42eb96cacc417ceffcbd4fa9c879d7f827939a Mon Sep 17 00:00:00 2001 From: Jason Rhinelander Date: Sat, 2 Jul 2022 20:19:24 -0300 Subject: [PATCH] Avoid Python's stupidly named "utcnow" function The function returns a timezone-adjusted value and thus appears to have absolutely nothing to do with UTC. Thanks Python. I think perhaps the function must have been a typo for "utcnot" because the function specifically returns something that is *not* UTC. --- observer.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/observer.py b/observer.py index 9d5b100..6734272 100644 --- a/observer.py +++ b/observer.py @@ -250,11 +250,12 @@ def parse_mempool(mempool_future): @app.context_processor def template_globals(): + now = datetime.now(timezone.utc) return { 'config': conf, 'server': { - 'datetime': datetime.now(timezone.utc), - 'timestamp': datetime.utcnow().timestamp(), + 'datetime': now, + 'timestamp': now.timestamp(), 'revision': git_rev, }, }