Commit c5057458 authored by 's avatar

Fixed two bugs in the string parsing logic of dt:

  * date strings of the form 5/27/1997 failed to
    save the year during parsing if a time string
    was also present.

  * european-style dates like 27/5/1997 were raising
    parsing errors - this was originally intentional
    as the original DateTime seemed to indicate that
    possibly ambiguous strings should fail. However,
    the existing c DateTime module does accept this
    format, so now this version does too for compatibility.
    NOTE THAT YOU ARE ALMOST CERTAIN TO HAVE PROBLEMS
    WITH THIS FORMAT AND SHOULD USE IT FOR COMPATIBILITY
    ONLY! Date strings with a day less than 13 will
    give incorrect results due to the abiguity.
parent 4c3e38f4
......@@ -44,7 +44,7 @@
"""Encapsulation of date/time values"""
__version__='$Revision: 1.12 $'[11:-2]
__version__='$Revision: 1.13 $'[11:-2]
import sys,os,regex,DateTimeZone
......@@ -387,7 +387,7 @@ class DateTime:
The module function Timezones() will return a list of the
timezones recognized by the DateTime module. Recognition of
timezone names is case-insensitive."""
timezone names is case-insensitive.""" #'
d=t=s=None
ac=len(args)
......@@ -707,11 +707,19 @@ class DateTime:
elif not month and ints[2] > 31:
month=ints[0]
day=ints[1]
year=ints[2]
del ints[:3]
else:
raise self.SyntaxError, string
if not month or month > 12: raise self.SyntaxError, string
if not month: raise SyntaxError,string
if month > 12:
# using euro format?
tmp=month
month=day
day=tmp
if year<100: year=year+CENTURY
leap = year%4==0 and (year%100!=0 or year%400==0)
if not day or day > self._month_len[leap][month]:
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment