aboutsummaryrefslogtreecommitdiff
path: root/src/utils/datetime.py
diff options
context:
space:
mode:
authorGravatar jesopo2020-01-30 14:58:32 +0000
committerGravatar jesopo2020-01-30 14:58:32 +0000
commit1674ef325b364056e08dd0be5f38c275956cf475 (patch)
tree629b0767805ac871e40f3112548074090294bc7c /src/utils/datetime.py
parentactually use count (for best_count), dont +=1 spec arg for non-consume (diff)
signature
add utils.datetime.seconds_since(); compare utcnow to datetime
Diffstat (limited to 'src/utils/datetime.py')
-rw-r--r--src/utils/datetime.py3
1 files changed, 3 insertions, 0 deletions
diff --git a/src/utils/datetime.py b/src/utils/datetime.py
index 0a916dbd..650893d1 100644
--- a/src/utils/datetime.py
+++ b/src/utils/datetime.py
@@ -43,6 +43,9 @@ def datetime_human(dt: _datetime.datetime, timespec: TimeSpec=TimeSpec.NORMAL):
def date_human(dt: _datetime.datetime, timespec: TimeSpec=TimeSpec.NORMAL):
return _datetime.datetime.strftime(dt, DATE_HUMAN)
+def seconds_since(dt: _datetime.datetime) -> float:
+ return (utcnow()-dt).total_seconds()
+
TIME_SECOND = 1
TIME_MINUTE = TIME_SECOND*60
TIME_HOUR = TIME_MINUTE*60