-
Notifications
You must be signed in to change notification settings - Fork 530
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
RF: Centralize to have a helper utcnow()
- Loading branch information
1 parent
f7a37ef
commit cd4bd5b
Showing
3 changed files
with
25 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
# emacs: -*- mode: python; py-indent-offset: 4; indent-tabs-mode: nil -*- | ||
# vi: set ft=python sts=4 ts=4 sw=4 et: | ||
""" | ||
Utilities for dates and time | ||
""" | ||
|
||
from datetime import datetime as dt | ||
import sys | ||
|
||
if sys.version_info >= (3, 11): | ||
from datetime import UTC | ||
|
||
def utcnow(): | ||
"""Adapter since 3.12 prior utcnow is deprecated, | ||
but not EOLed 3.8 does not have datetime.UTC""" | ||
return dt.now(UTC) | ||
|
||
else: | ||
utcnow = dt.utcnow |