Skip to content

Commit fd9b7a2

Browse files
committed
[3009273] and [2875065] update dateutil to 1.5
svn path=/trunk/matplotlib/; revision=8388
1 parent b7b4e8b commit fd9b7a2

File tree

9 files changed

+102
-64
lines changed

9 files changed

+102
-64
lines changed

lib/dateutil/NEWS

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,19 @@
1+
2+
Version 1.5
3+
-----------
4+
5+
- As reported by Mathieu Bridon, rrules were matching the bysecond rules
6+
incorrectly against byminute in some circumstances when the SECONDLY
7+
frequency was in use, due to a copy & paste bug. The problem has been
8+
unittested and corrected.
9+
10+
- Adam Ryan reported a problem in the relativedelta implementation which
11+
affected the yearday parameter in the month of January specifically.
12+
This has been unittested and fixed.
13+
14+
- Updated timezone information.
15+
16+
117
Version 1.4.1
218
-------------
319

lib/dateutil/__init__.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
"""
2-
Copyright (c) 2003-2005 Gustavo Niemeyer <gustavo@niemeyer.net>
2+
Copyright (c) 2003-2010 Gustavo Niemeyer <gustavo@niemeyer.net>
33
44
This module offers extensions to the standard python 2.3+
55
datetime module.
66
"""
77
__author__ = "Gustavo Niemeyer <gustavo@niemeyer.net>"
88
__license__ = "PSF License"
9-
__version__ = "1.2-mpl"
9+
__version__ = "1.5"

lib/dateutil/easter.py

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
"""
2-
Copyright (c) 2003-2005 Gustavo Niemeyer <gustavo@niemeyer.net>
2+
Copyright (c) 2003-2007 Gustavo Niemeyer <gustavo@niemeyer.net>
33
44
This module offers extensions to the standard python 2.3+
55
datetime module.
@@ -70,23 +70,23 @@ def easter(year, method=EASTER_WESTERN):
7070
if method < 3:
7171
# Old method
7272
i = (19*g+15)%30
73-
j = (y+y/4+i)%7
73+
j = (y+y//4+i)%7
7474
if method == 2:
7575
# Extra dates to convert Julian to Gregorian date
7676
e = 10
7777
if y > 1600:
78-
e = e+y/100-16-(y/100-16)/4
78+
e = e+y//100-16-(y//100-16)//4
7979
else:
8080
# New method
81-
c = y/100
82-
h = (c-c/4-(8*c+13)/25+19*g+15)%30
83-
i = h-(h/28)*(1-(h/28)*(29/(h+1))*((21-g)/11))
84-
j = (y+y/4+i+2-c+c/4)%7
81+
c = y//100
82+
h = (c-c//4-(8*c+13)//25+19*g+15)%30
83+
i = h-(h//28)*(1-(h//28)*(29//(h+1))*((21-g)//11))
84+
j = (y+y//4+i+2-c+c//4)%7
8585

8686
# p can be from -6 to 56 corresponding to dates 22 March to 23 May
8787
# (later dates apply to method 2, although 23 May never actually occurs)
8888
p = i-j+e
89-
d = 1+(p+27+(p+6)/40)%31
90-
m = 3+(p+26)/30
91-
return datetime.date(y,m,d)
89+
d = 1+(p+27+(p+6)//40)%31
90+
m = 3+(p+26)//30
91+
return datetime.date(int(y),int(m),int(d))
9292

lib/dateutil/parser.py

Lines changed: 45 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,31 @@
11
# -*- coding:iso-8859-1 -*-
22
"""
3-
Copyright (c) 2003-2005 Gustavo Niemeyer <gustavo@niemeyer.net>
3+
Copyright (c) 2003-2007 Gustavo Niemeyer <gustavo@niemeyer.net>
44
55
This module offers extensions to the standard python 2.3+
66
datetime module.
77
"""
88
__author__ = "Gustavo Niemeyer <gustavo@niemeyer.net>"
99
__license__ = "PSF License"
1010

11-
import os.path
11+
import datetime
1212
import string
13-
import sys
1413
import time
14+
import sys
15+
import os
16+
17+
try:
18+
from cStringIO import StringIO
19+
except ImportError:
20+
from StringIO import StringIO
1521

16-
import datetime
1722
import relativedelta
1823
import tz
1924

25+
2026
__all__ = ["parse", "parserinfo"]
2127

28+
2229
# Some pointers:
2330
#
2431
# http://www.cl.cam.ac.uk/~mgk25/iso-time.html
@@ -28,12 +35,9 @@
2835
# http://search.cpan.org/author/MUIR/Time-modules-2003.0211/lib/Time/ParseDate.pm
2936
# http://stein.cshl.org/jade/distrib/docs/java.text.SimpleDateFormat.html
3037

31-
try:
32-
from cStringIO import StringIO
33-
except ImportError:
34-
from StringIO import StringIO
3538

36-
class _timelex:
39+
class _timelex(object):
40+
3741
def __init__(self, instream):
3842
if isinstance(instream, basestring):
3943
instream = StringIO(instream)
@@ -139,6 +143,7 @@ def split(cls, s):
139143
return list(cls(s))
140144
split = classmethod(split)
141145

146+
142147
class _resultbase(object):
143148

144149
def __init__(self):
@@ -156,7 +161,8 @@ def _repr(self, classname):
156161
def __repr__(self):
157162
return self._repr(self.__class__.__name__)
158163

159-
class parserinfo:
164+
165+
class parserinfo(object):
160166

161167
# m from a.m/p.m, t from ISO T separator
162168
JUMP = [" ", ".", ",", ";", "-", "/", "'",
@@ -204,7 +210,7 @@ def __init__(self, dayfirst=False, yearfirst=False):
204210
self.yearfirst = yearfirst
205211

206212
self._year = time.localtime().tm_year
207-
self._century = self._year/100*100
213+
self._century = self._year//100*100
208214

209215
def _convert(self, lst):
210216
dct = {}
@@ -281,15 +287,10 @@ def validate(self, res):
281287
return True
282288

283289

284-
class parser:
290+
class parser(object):
285291

286-
def __init__(self, info=parserinfo):
287-
if issubclass(info, parserinfo):
288-
self.info = parserinfo()
289-
elif isinstance(info, parserinfo):
290-
self.info = info
291-
else:
292-
raise TypeError, "Unsupported parserinfo type"
292+
def __init__(self, info=None):
293+
self.info = info or parserinfo()
293294

294295
def parse(self, timestr, default=None,
295296
ignoretz=False, tzinfos=None,
@@ -360,9 +361,11 @@ def _parse(self, timestr, dayfirst=None, yearfirst=None, fuzzy=False):
360361

361362
# Check if it's a number
362363
try:
363-
value = float(l[i])
364+
value_repr = l[i]
365+
value = float(value_repr)
364366
except ValueError:
365367
value = None
368+
366369
if value is not None:
367370
# Token is a number
368371
len_li = len(l[i])
@@ -386,10 +389,7 @@ def _parse(self, timestr, dayfirst=None, yearfirst=None, fuzzy=False):
386389
# 19990101T235959[.59]
387390
res.hour = int(s[:2])
388391
res.minute = int(s[2:4])
389-
value = float(s[4:])
390-
res.second = int(value)
391-
if value%1:
392-
res.microsecond = int(1000000*(value%1))
392+
res.second, res.microsecond = _parsems(s[4:])
393393
elif len_li == 8:
394394
# YYYYMMDD
395395
s = l[i-1]
@@ -423,15 +423,15 @@ def _parse(self, timestr, dayfirst=None, yearfirst=None, fuzzy=False):
423423
if value%1:
424424
res.second = int(60*(value%1))
425425
elif idx == 2:
426-
res.second = int(value)
427-
if value%1:
428-
res.microsecond = int(1000000*(value%1))
426+
res.second, res.microsecond = \
427+
_parsems(value_repr)
429428
i += 1
430429
if i >= len_l or idx == 2:
431430
break
432431
# 12h00
433432
try:
434-
value = float(l[i])
433+
value_repr = l[i]
434+
value = float(value_repr)
435435
except ValueError:
436436
break
437437
else:
@@ -451,10 +451,7 @@ def _parse(self, timestr, dayfirst=None, yearfirst=None, fuzzy=False):
451451
res.second = int(60*(value%1))
452452
i += 1
453453
if i < len_l and l[i] == ':':
454-
value = float(l[i+1])
455-
res.second = int(value)
456-
if value%1:
457-
res.microsecond = int(1000000*(value%1))
454+
res.second, res.microsecond = _parsems(l[i+1])
458455
i += 2
459456
elif i < len_l and l[i] in ('-', '/', '.'):
460457
sep = l[i]
@@ -699,7 +696,8 @@ def parse(timestr, parserinfo=None, **kwargs):
699696
else:
700697
return DEFAULTPARSER.parse(timestr, **kwargs)
701698

702-
class _tzparser:
699+
700+
class _tzparser(object):
703701

704702
class _result(_resultbase):
705703

@@ -743,6 +741,8 @@ def parse(self, tzstr):
743741
if (i < len_l and
744742
(l[i] in ('+', '-') or l[i][0] in "0123456789")):
745743
if l[i] in ('+', '-'):
744+
# Yes, that's right. See the TZ variable
745+
# documentation.
746746
signal = (1,-1)[l[i] == '+']
747747
i += 1
748748
else:
@@ -865,11 +865,22 @@ def parse(self, tzstr):
865865

866866
except (IndexError, ValueError, AssertionError):
867867
return None
868-
868+
869869
return res
870870

871+
871872
DEFAULTTZPARSER = _tzparser()
872873
def _parsetz(tzstr):
873874
return DEFAULTTZPARSER.parse(tzstr)
874875

876+
877+
def _parsems(value):
878+
"""Parse a I[.F] seconds value into (seconds, microseconds)."""
879+
if "." not in value:
880+
return int(value), 0
881+
else:
882+
i, f = value.split(".")
883+
return int(i), int(f.ljust(6, "0")[:6])
884+
885+
875886
# vim:ts=4:sw=4:et

lib/dateutil/relativedelta.py

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
"""
2-
Copyright (c) 2003-2005 Gustavo Niemeyer <gustavo@niemeyer.net>
2+
Copyright (c) 2003-2010 Gustavo Niemeyer <gustavo@niemeyer.net>
33
44
This module offers extensions to the standard python 2.3+
55
datetime module.
@@ -190,7 +190,7 @@ def __init__(self, dt1=None, dt2=None,
190190
if yday <= ydays:
191191
self.month = idx+1
192192
if idx == 0:
193-
self.day = ydays
193+
self.day = yday
194194
else:
195195
self.day = yday-ydayidx[idx-1]
196196
break
@@ -201,27 +201,27 @@ def __init__(self, dt1=None, dt2=None,
201201

202202
def _fix(self):
203203
if abs(self.microseconds) > 999999:
204-
s = self.microseconds/abs(self.microseconds)
204+
s = self.microseconds//abs(self.microseconds)
205205
div, mod = divmod(self.microseconds*s, 1000000)
206206
self.microseconds = mod*s
207207
self.seconds += div*s
208208
if abs(self.seconds) > 59:
209-
s = self.seconds/abs(self.seconds)
209+
s = self.seconds//abs(self.seconds)
210210
div, mod = divmod(self.seconds*s, 60)
211211
self.seconds = mod*s
212212
self.minutes += div*s
213213
if abs(self.minutes) > 59:
214-
s = self.minutes/abs(self.minutes)
214+
s = self.minutes//abs(self.minutes)
215215
div, mod = divmod(self.minutes*s, 60)
216216
self.minutes = mod*s
217217
self.hours += div*s
218218
if abs(self.hours) > 23:
219-
s = self.hours/abs(self.hours)
219+
s = self.hours//abs(self.hours)
220220
div, mod = divmod(self.hours*s, 24)
221221
self.hours = mod*s
222222
self.days += div*s
223223
if abs(self.months) > 11:
224-
s = self.months/abs(self.months)
224+
s = self.months//abs(self.months)
225225
div, mod = divmod(self.months*s, 12)
226226
self.months = mod*s
227227
self.years += div*s
@@ -235,7 +235,7 @@ def _fix(self):
235235
def _set_months(self, months):
236236
self.months = months
237237
if abs(self.months) > 11:
238-
s = self.months/abs(self.months)
238+
s = self.months//abs(self.months)
239239
div, mod = divmod(self.months*s, 12)
240240
self.months = mod*s
241241
self.years = div*s

lib/dateutil/rrule.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
"""
2-
Copyright (c) 2003-2005 Gustavo Niemeyer <gustavo@niemeyer.net>
2+
Copyright (c) 2003-2010 Gustavo Niemeyer <gustavo@niemeyer.net>
33
44
This module offers extensions to the standard python 2.3+
55
datetime module.
@@ -439,7 +439,7 @@ def _iter(self):
439439
(freq >= MINUTELY and
440440
self._byminute and minute not in self._byminute) or
441441
(freq >= SECONDLY and
442-
self._bysecond and minute not in self._bysecond)):
442+
self._bysecond and second not in self._bysecond)):
443443
timeset = ()
444444
else:
445445
timeset = gettimeset(hour, minute, second)

0 commit comments

Comments
 (0)