Last active
August 1, 2016 18:16
-
-
Save dmyersturnbull/e83bea03e76c8ffa2ba21b21bb8859f4 to your computer and use it in GitHub Desktop.
YYYY-mm-dd_HH-MM-SS timestamp.
This file contains hidden or 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
| import datetime | |
| def format_time(time: datetime.datetime) -> str: | |
| """Standard timestamp format. Ex: 2016-05-02_22_35_56.""" | |
| return time.strftime("%Y-%m-%d_%H-%M-%S") | |
| def timestamp() -> str: | |
| """Standard timestamp of time now. Ex: 2016-05-02_22_35_56.""" | |
| return format_time(datetime.datetime.now()) | |
| def timestamp_path(path: str) -> str: | |
| """Standard way to label a file path with a timestamp.""" | |
| return "{}-{}".format(path, timestamp()) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment