Skip to content

Commit ca1148a

Browse files
committed
Python 2.6 (used in production) doesn't have the total_seconds() method on datetime.timedelta -- use a module function instead.
- Legacy-Id: 4157
1 parent 56b8f3e commit ca1148a

1 file changed

Lines changed: 5 additions & 1 deletion

File tree

ietf/idrfc/mirror_rfc_index.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,10 @@ def log(line):
5353
else:
5454
log_data += line + "\n"
5555

56+
# python before 2.7 doesn't have the total_seconds method on datetime.timedelta.
57+
def total_seconds(td):
58+
return (td.microseconds + (td.seconds + td.days * 24 * 3600) * 10**6) / 10**6
59+
5660
def parse(response):
5761
def getChildText(parentNode, tagName):
5862
for node in parentNode.childNodes:
@@ -262,7 +266,7 @@ def insert_to_databaseREDESIGN(data):
262266
if abs(pubdate - synthesized) > timedelta(days=60):
263267
synthesized = pubdate
264268
else:
265-
direction = -1 if (pubdate - synthesized).total_seconds() < 0 else +1
269+
direction = -1 if total_seconds(pubdate - synthesized) < 0 else +1
266270
while synthesized.month != pubdate.month or synthesized.year != pubdate.year:
267271
synthesized += timedelta(days=direction)
268272
e.time = synthesized

0 commit comments

Comments
 (0)