Commits

Mike Fogel  committed 851a2c3

Support microseconds on sqlite

  • Participants
  • Parent commits 633049c

Comments (0)

Files changed (2)

File timedelta/helpers.py

     """
     if string == "":
         raise TypeError("'%s' is not a valid time interval" % string)
-    # This is the format we get from sometimes Postgres, and from serialization
+    # This is the format we get from sometimes Postgres, sqlite,
+    # and from serialization
     d = re.match(r'((?P<days>\d+) days?,? )?(?P<hours>\d+):'
-                 r'(?P<minutes>\d+)(:(?P<seconds>\d+))?',
+                 r'(?P<minutes>\d+)(:(?P<seconds>[\.\d]+))?',
                  unicode(string))
     if d: 
         d = d.groupdict(0)

File timedelta/tests.py

         datetime.timedelta(1)
         >>> t.clean('1 day, 0:00:00')
         datetime.timedelta(1)
+        >>> t.clean('1 day, 8:42:42.342')
+        datetime.timedelta(1, 31362, 342000)
+        >>> t.clean('3 days, 8:42:42.342161')
+        datetime.timedelta(3, 31362, 342161)
         >>> t.clean('5 day, 8:42:42')
         datetime.timedelta(5, 31362)
         >>> t.clean('1 days')