add utils.datetime.seconds_since(); compare utcnow to datetime

This commit is contained in:
jesopo 2020-01-30 14:58:32 +00:00
parent 82d20869e1
commit 1674ef325b

View file

@ -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