Created
November 28, 2022 01:46
-
-
Save teleprint-me/c644ccdeaf0b064448184b3846cab3ad to your computer and use it in GitHub Desktop.
Simplify timestamps in python
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
from datetime import date, datetime | |
from dateutil import parser | |
def to_datetime(value: str) -> datetime: | |
return parser.parse(value) | |
def to_iso(value: datetime) -> str: | |
return value.isoformat() | |
def to_date(value: str) -> str: | |
return date.isoformat(parser.parse(value)) | |
def timestamp() -> str: | |
return datetime.now().isoformat() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment