Ticket #3 (closed defect: fixed)

Opened 2 years ago

Last modified 2 years ago

parseDatetime() does not parse ISO format strings correctly

Reported by: atis Assigned to: valts
Priority: major Milestone:
Component: server core Version: 0.6.1
Keywords: Cc:

Description

isoFormat regexp matches month-date in the wrong order. Also the microsecond multiplier (* 1000) does not seem to be necessary with iso format.

@@ -329,8 +329,8 @@
 isoFormat = re.compile('''
        ^
        (?P<year>               \d{1,4})-       # year
-       (?P<date>               \d{1,2})-               # date
-       (?P<month>              \d{1,2})                # month
+       (?P<month>              \d{1,2})-               # month
+       (?P<date>               \d{1,2})                # date
        \s+
        (?P<hour>               \d{1,2}):       # hour
        (?P<minute>             \d{1,2}):       # minute
@@ -384,8 +384,10 @@
        if format == 'cisco':
                mstr = 'JanFebMarAprMayJunJulAugSepOctNovDec'
                month = (mstr.find(matched.group('month')) + 3) / 3
+               microsec = int(matched.group('microsec')) * 1000
        else:
                month = int(matched.group('month'))
+               microsec = int(matched.group('microsec'))
        
        # create new datetime class instance
        parsedDatetime = datetime.datetime(
@@ -395,7 +397,7 @@
                int(matched.group('hour')),
                int(matched.group('minute')),
                int(matched.group('second')),
-               int(matched.group('microsec')) * 1000,
+               microsec,
                None    # set time zone to default - UTC. It is possible to substitute it later with appropiate tzinfo subclass
                )

Change History

11/23/06 20:50:36 changed by valts

  • status changed from new to assigned.

11/23/06 21:15:41 changed by valts

  • status changed from assigned to closed.
  • resolution set to fixed.

Commited into trunk. Will be pulled to v_0_6 branch also.