Skip to content

Commit 3487ce8

Browse files
committed
issue2117897: Fixed two more rounding to 60.0 seconds in date.py
This caused exceptions in real-world data as reported in the issue by Kenny Johansson, Malte Helmert and me. Change them to 59.999 as was done in the fix for issue2550802.
1 parent f1a02e5 commit 3487ce8

File tree

2 files changed

+6
-1
lines changed

2 files changed

+6
-1
lines changed

CHANGES.txt

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ Entries are given with the most recent entry first.
33
Each entry has the developer who committed the change in brackets.
44
Entries without name were done by Richard Jones.
55

6-
2013-??-??: 1.5.1
6+
2014-??-??: 1.5.1
77

88
Features:
99

@@ -55,6 +55,9 @@ Fixed:
5555
necessary changes to your templates, the escaping now happens in the
5656
template and not in the roundup code. So if you don't make the
5757
necessary changes *you are vulnerable*. (Ralf Schlatterbeck)
58+
- issue2117897: Fixed two more places in date.py where seconds can be
59+
rounded to 60.0 and causing exceptions. Change them to 59.999 as was
60+
done in the fix for issue2550802. (Thomas Arendsen Hein)
5861

5962

6063
2013-07-06: 1.5.0

roundup/date.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -145,6 +145,7 @@ def get_timezone(tz):
145145

146146
def _utc_to_local(y,m,d,H,M,S,tz):
147147
TZ = get_timezone(tz)
148+
S = min(S, 59.999)
148149
frac = S - int(S)
149150
dt = datetime.datetime(y, m, d, H, M, int(S), tzinfo=UTC)
150151
y,m,d,H,M,S = dt.astimezone(TZ).timetuple()[:6]
@@ -269,6 +270,7 @@ def __init__(self, spec='.', offset=0, add_granularity=False,
269270
spec = spec.get_tuple()
270271
try:
271272
y,m,d,H,M,S,x,x,x = spec
273+
S = min(S, 59.999)
272274
frac = S - int(S)
273275
self.year, self.month, self.day, self.hour, self.minute, \
274276
self.second = _local_to_utc(y, m, d, H, M, S, offset)

0 commit comments

Comments
 (0)