Skip to content

Commit 43805c6

Browse files
committed
view: fix format_ts, use existing utc timestamp_to_sec conversion for %s
1 parent 7ece05d commit 43805c6

File tree

2 files changed

+7
-8
lines changed

2 files changed

+7
-8
lines changed

pywb/webapp/test/test_view_filters.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
"""
2-
>>> format_ts('201412261010')
3-
'Fri, Dec 26 2014 10:10:59'
2+
>>> format_ts('20141226101000')
3+
'Fri, Dec 26 2014 10:10:00'
44
5-
>>> format_ts('201412261010', '%s')
6-
1419617459000
5+
>>> format_ts('20141226101000', '%s')
6+
1419588600
77
88
>>> is_wb_handler(DebugEchoHandler())
99
False

pywb/webapp/views.py

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,9 @@
1-
from pywb.utils.timeutils import timestamp_to_datetime
1+
from pywb.utils.timeutils import timestamp_to_datetime, timestamp_to_sec
22
from pywb.framework.wbrequestresponse import WbResponse
33
from pywb.framework.memento import make_timemap, LINK_FORMAT
44

55
import urlparse
66
import logging
7-
import time
87

98
from os import path
109
from itertools import imap
@@ -38,10 +37,10 @@ def __call__(self, func):
3837
# Filters
3938
@template_filter()
4039
def format_ts(value, format_='%a, %b %d %Y %H:%M:%S'):
41-
value = timestamp_to_datetime(value)
4240
if format_ == '%s':
43-
return int(time.mktime(value.timetuple()) * 1000)
41+
return timestamp_to_sec(value)
4442
else:
43+
value = timestamp_to_datetime(value)
4544
return value.strftime(format_)
4645

4746

0 commit comments

Comments
 (0)