mirror of
https://github.com/webrecorder/pywb.git
synced 2025-03-24 06:59:52 +01:00
timeutils: add sec_to_timestamp() func
This commit is contained in:
parent
da0623fbbb
commit
b5e70f5dc6
@ -244,6 +244,7 @@ def timestamp_to_sec(string):
|
|||||||
>>> timestamp_to_sec('20131226095010')
|
>>> timestamp_to_sec('20131226095010')
|
||||||
1388051410
|
1388051410
|
||||||
|
|
||||||
|
# rounds to end of 2014
|
||||||
>>> timestamp_to_sec('2014')
|
>>> timestamp_to_sec('2014')
|
||||||
1420070399
|
1420070399
|
||||||
"""
|
"""
|
||||||
@ -251,6 +252,18 @@ def timestamp_to_sec(string):
|
|||||||
return calendar.timegm(timestamp_to_datetime(string).utctimetuple())
|
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):
|
def timestamp_to_http_date(string):
|
||||||
"""
|
"""
|
||||||
>>> timestamp_to_http_date('20131226095000')
|
>>> timestamp_to_http_date('20131226095000')
|
||||||
|
Loading…
x
Reference in New Issue
Block a user