1
0
mirror of https://github.com/gryf/slack-backup.git synced 2025-12-17 19:40:21 +01:00

Moved fromtimestamp function to utils module

This commit is contained in:
2018-05-03 18:44:25 +02:00
parent 43b830c3d1
commit c33d2fad50
2 changed files with 16 additions and 13 deletions

View File

@@ -1,6 +1,7 @@
"""
Some utils functions. Jsut to not copypaste the code around
"""
from datetime import datetime
import errno
import os
import logging
@@ -42,3 +43,13 @@ def same_files(file1, file2):
hash2 = hashlib.sha256(fobj.read())
return hash1.hexdigest() == hash2.hexdigest()
def fromtimestamp(timestamp):
"""
Return datetime object from provided timestamp. If timestamp argument is
falsy, datetime object placed in January 1970 will be retuned.
"""
if not timestamp:
return datetime.utcfromtimestamp(0)
return datetime.fromtimestamp(timestamp)