mirror of
https://github.com/webrecorder/pywb.git
synced 2025-03-24 06:59:52 +01:00
view: fix format_ts, use existing utc timestamp_to_sec conversion for %s
This commit is contained in:
parent
7ece05d022
commit
43805c67ef
@ -1,9 +1,9 @@
|
|||||||
"""
|
"""
|
||||||
>>> format_ts('201412261010')
|
>>> format_ts('20141226101000')
|
||||||
'Fri, Dec 26 2014 10:10:59'
|
'Fri, Dec 26 2014 10:10:00'
|
||||||
|
|
||||||
>>> format_ts('201412261010', '%s')
|
>>> format_ts('20141226101000', '%s')
|
||||||
1419617459000
|
1419588600
|
||||||
|
|
||||||
>>> is_wb_handler(DebugEchoHandler())
|
>>> is_wb_handler(DebugEchoHandler())
|
||||||
False
|
False
|
||||||
|
@ -1,10 +1,9 @@
|
|||||||
from pywb.utils.timeutils import timestamp_to_datetime
|
from pywb.utils.timeutils import timestamp_to_datetime, timestamp_to_sec
|
||||||
from pywb.framework.wbrequestresponse import WbResponse
|
from pywb.framework.wbrequestresponse import WbResponse
|
||||||
from pywb.framework.memento import make_timemap, LINK_FORMAT
|
from pywb.framework.memento import make_timemap, LINK_FORMAT
|
||||||
|
|
||||||
import urlparse
|
import urlparse
|
||||||
import logging
|
import logging
|
||||||
import time
|
|
||||||
|
|
||||||
from os import path
|
from os import path
|
||||||
from itertools import imap
|
from itertools import imap
|
||||||
@ -38,10 +37,10 @@ class template_filter(object):
|
|||||||
# Filters
|
# Filters
|
||||||
@template_filter()
|
@template_filter()
|
||||||
def format_ts(value, format_='%a, %b %d %Y %H:%M:%S'):
|
def format_ts(value, format_='%a, %b %d %Y %H:%M:%S'):
|
||||||
value = timestamp_to_datetime(value)
|
|
||||||
if format_ == '%s':
|
if format_ == '%s':
|
||||||
return int(time.mktime(value.timetuple()) * 1000)
|
return timestamp_to_sec(value)
|
||||||
else:
|
else:
|
||||||
|
value = timestamp_to_datetime(value)
|
||||||
return value.strftime(format_)
|
return value.strftime(format_)
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user