implement 'datetime_to_timestamp()'

and rename 'to_timestamp()'
to the more descriptive 'datetime_to_timestamp_string()'
This commit is contained in:
Mike Fährmann
2022-03-23 22:20:37 +01:00
parent c0c1277c5f
commit 29db716a63
4 changed files with 19 additions and 5 deletions

View File

@@ -173,8 +173,13 @@ def to_string(value):
return str(value)
def to_timestamp(dt):
"""Convert naive datetime to UTC timestamp string"""
def datetime_to_timestamp(dt):
"""Convert naive UTC datetime to timestamp"""
return (dt - EPOCH) / SECOND
def datetime_to_timestamp_string(dt):
"""Convert naive UTC datetime to timestamp string"""
try:
return str((dt - EPOCH) // SECOND)
except Exception: