[ZCM] [ZC] 1897/ 6 Comment "DateTime bug"
"Collector: Zope Bugs, Features, and Patches ..." <[email protected]> Thu, 15 Mar 2007 13:41:36 -0400
| Newsgroups | gmane.comp.web.zope.devel.collector-monitor |
|---|---|
| Message-ID | <[email protected]> |
Issue #1897 Update (Comment) "DateTime bug"
Status Accepted, Zope/bug medium
To followup, visit:
http://www.zope.org/Collectors/Zope/1897
==============================================================
= Comment - Entry #6 by jhreis on Mar 15, 2007 1:41 pm
I made a diff against the current trunk and the result is:
DateTime.py
1117a1118,1119
> else:
> raise DateError, st
________________________________________
= Comment - Entry #5 by ajung on Jan 13, 2007 5:35 am
Please submit a full diff against the current trunk
________________________________________
= Assign - Entry #4 by ajung on Jun 15, 2006 4:43 am
Status: Pending => Accepted
Supporters added: ajung
Reminder for myself to check the patch
________________________________________
= Comment - Entry #3 by jhreis on Oct 18, 2005 4:37 pm
I wrote the patch unit test as requested (see below). It's my first unit test so I inserted this test in testDateTime.py, ran it several times with random values to day (13..99) and month (32..99). It worked well and the patch didn't cause no side effects in the other tests.
def testBug1897(self):
''' Dates in the format 'dd/mm/yyyy' where dd > 12 and mm > 31
didn't raise an error. Instead, the current date was returned.
'''
wrongDate = '13/32/2005'
self.assertRaises(DateTime.DateError,DateTime,wrongDate)
________________________________________
= Comment - Entry #2 by ajung on Sep 24, 2005 6:39 am
Please provide unittests for your patch.
________________________________________
= Request - Entry #1 by jhreis on Sep 12, 2005 11:46 am
If you submit a date in the format 'dd/mm/yyyy' where
dd > 12
mm > 31
the DateTime module doesn't raise an error. Instead, it returns the current date.
It's possible to reproduce the error, through this script:
for i in range(1,50):
sdat = '13/'+str(i)+'/1980'
try:
data = DateTime(sdat)
print data.strftime('%d/%m/%Y')
except:
print 'erro ', sdat
return printed
I think that this bug can be eliminated if we include an statement that raises an error in the line 1064 of the _parse method:
1056 if ints[1] > 31:
1057 year=ints[1]
1058 if ints[0] > 12 and ints[2] <= 12:
1059 day=ints[0]
1060 month=ints[2]
1061 elif ints[2] > 12 and ints[0] <= 12:
1062 day=ints[2]
1063 month=ints[0]
1064 else:
1065 raise 'DateError', st
I also tested Zope 2.8.0-final and found the same bug.
==============================================================