Skip to content
Snippets Groups Projects
Commit d2d00f48 authored by David Trattnig's avatar David Trattnig
Browse files

refactor: add timestamp utility

parent 45544fe3
No related branches found
No related tags found
1 merge request!35ORM-less scheduling
......@@ -34,14 +34,23 @@ class SimpleUtil:
"""
@staticmethod
def to_datetime(datetime_str: str):
def string_to_datetime(datetime_str: str):
"""
Convert a timezone aware date-time string into `datetime`.
Convert a ISO 8601 date-time string into `datetime`.
"""
if datetime_str:
return datetime.datetime.fromisoformat(datetime_str)
return None
@staticmethod
def timestamp_to_datetime(timestamp: float):
"""
Convert a timestamp to datetime.
"""
if timestamp:
return datetime.datetime.fromtimestamp(timestamp)
return None
@staticmethod
def fmt_time(timestamp: int):
"""
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment