Created
March 29, 2016 03:34
-
-
Save itkr/593e34ef4d5b4c60b8c6 to your computer and use it in GitHub Desktop.
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
class TransformTools(object): | |
@staticmethod | |
def str_to_time(log_date_str): | |
DATETIME_FORMAT = '%Y/%m/%d %H:%M:%S' | |
return datetime.strptime(log_date_str, DATETIME_FORMAT) | |
@staticmethod | |
def datetime2epoch(target_datetime): | |
return int(time.mktime(target_datetime.timetuple())) | |
@staticmethod | |
def epoch2datetime(epoch): | |
return datetime.fromtimestamp(int(epoch)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment