1. Matthew Schinckel
  2. django-timedelta-field

Commits

Matthew Schinckel  committed 6bd8ae9

Remove redundant check.

  • Participants
  • Parent commits c42f4eb
  • Branches default

Comments (0)

Files changed (2)

File timedelta/fields.py

View file
  • Ignore whitespace
             return value
         if isinstance(value, int):
             return datetime.timedelta(seconds=value)
-        if value == "":
-            return datetime.timedelta(0)
         return parse(value)
     
     def get_prep_value(self, value):

File timedelta/helpers.py

View file
  • Ignore whitespace
     Traceback (most recent call last):
     ...
     TypeError: '2 ss' is not a valid time interval
+    >>> parse("")
+    datetime.timedelta(0)
     
     """
     # This is the format we get from sometimes Postgres, and from serialization
                      unicode(string))
         if not d:
             raise TypeError("'%s' is not a valid time interval" % string)
-        d = d.groupdict()
+        d = d.groupdict(0)
     
-    return datetime.timedelta(**dict(( (k, float(v)) for k,v in d.items() 
-        if v is not None )))
+    return datetime.timedelta(**dict(( (k, float(v)) for k,v in d.items())))
 
 
 def divide(obj1, obj2, as_float=False):