1
0
mirror of https://github.com/webrecorder/pywb.git synced 2025-03-15 00:03:28 +01:00

timeutils: add sec_to_timestamp() func

This commit is contained in:
Ilya Kreymer 2014-03-27 14:24:49 -07:00
parent da0623fbbb
commit b5e70f5dc6

View File

@ -244,6 +244,7 @@ def timestamp_to_sec(string):
>>> timestamp_to_sec('20131226095010')
1388051410
# rounds to end of 2014
>>> timestamp_to_sec('2014')
1420070399
"""
@ -251,6 +252,18 @@ def timestamp_to_sec(string):
return calendar.timegm(timestamp_to_datetime(string).utctimetuple())
def sec_to_timestamp(secs):
"""
>>> sec_to_timestamp(1388051410)
'20131226095010'
>>> sec_to_timestamp(1420070399)
'20141231235959'
"""
return datetime_to_timestamp(datetime.datetime.utcfromtimestamp(secs))
def timestamp_to_http_date(string):
"""
>>> timestamp_to_http_date('20131226095000')