implement 'text.parse_timestamp()'
This commit is contained in:
@@ -11,6 +11,7 @@
|
||||
import re
|
||||
import html
|
||||
import os.path
|
||||
import datetime
|
||||
import urllib.parse
|
||||
|
||||
|
||||
@@ -214,6 +215,14 @@ def parse_query(qs):
|
||||
return result
|
||||
|
||||
|
||||
def parse_timestamp(ts, default=None):
|
||||
"""Create a datetime object from a unix timestamp"""
|
||||
try:
|
||||
return datetime.datetime.fromtimestamp(int(ts))
|
||||
except (TypeError, ValueError, OverflowError):
|
||||
return default
|
||||
|
||||
|
||||
if os.name == "nt":
|
||||
clean_path = clean_path_windows
|
||||
else:
|
||||
|
||||
Reference in New Issue
Block a user