Skip to content

Commit 209beb6

Browse files
author
Richard Jones
committed
Handle rounding of seconds generating invalid date values
1 parent 0348a69 commit 209beb6

File tree

2 files changed

+5
-1
lines changed

2 files changed

+5
-1
lines changed

CHANGES.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ Fixed:
66
- If-Modified-Since handling was broken
77
- Updated documentation for customising hard-coded searches in page.html
88
- Updated Windows installation docs (thanks Bo Berglund)
9+
- Handle rounding of seconds generating invalid date values
910

1011

1112
2006-12-19 1.3.2

roundup/date.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
# BASIS, AND THERE IS NO OBLIGATION WHATSOEVER TO PROVIDE MAINTENANCE,
1616
# SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS.
1717
#
18-
# $Id: date.py,v 1.88 2006-09-09 05:50:17 richard Exp $
18+
# $Id: date.py,v 1.89 2006-12-28 22:38:02 richard Exp $
1919

2020
"""Date, time and time interval handling.
2121
"""
@@ -278,6 +278,7 @@ def __init__(self, spec='.', offset=0, add_granularity=0, translator=i18n):
278278
self.second = _local_to_utc(y, m, d, H, M, S, offset)
279279
# we lost the fractional part
280280
self.second = self.second + frac
281+
if str(self.second) == '60.0': self.second = 59.9
281282
except:
282283
raise ValueError, 'Unknown spec %r' % (spec,)
283284

@@ -313,6 +314,7 @@ def set(self, spec, offset=0, date_re=date_re,
313314
y,m,d,H,M,S,x,x,x = time.gmtime(ts)
314315
# gmtime loses the fractional seconds
315316
S = S + frac
317+
if str(S) == '60.0': S = 59.9
316318

317319
# whether we need to convert to UTC
318320
adjust = False
@@ -355,6 +357,7 @@ def set(self, spec, offset=0, date_re=date_re,
355357
self.second = y, m, d, H, M, S
356358
# we lost the fractional part along the way
357359
self.second = self.second + frac
360+
if str(self.second) == '60.0': self.second = 59.9
358361

359362
if info.get('o', None):
360363
try:

0 commit comments

Comments
 (0)