Code

oops
authorrichard <richard@57a73879-2fb5-44c3-a270-3262357dd7e2>
Mon, 23 Sep 2002 07:09:15 +0000 (07:09 +0000)
committerrichard <richard@57a73879-2fb5-44c3-a270-3262357dd7e2>
Mon, 23 Sep 2002 07:09:15 +0000 (07:09 +0000)
git-svn-id: http://svn.roundup-tracker.org/svnroot/roundup/trunk@1208 57a73879-2fb5-44c3-a270-3262357dd7e2

roundup/date.py

index e048927d7aa018e42d14f892b0014f425b4c91b6..a016133ddc4c2e7b08a3387c06cd21b58a06b520 100644 (file)
@@ -15,7 +15,7 @@
 # BASIS, AND THERE IS NO OBLIGATION WHATSOEVER TO PROVIDE MAINTENANCE,
 # SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS.
 # 
-# $Id: date.py,v 1.29 2002-09-23 06:48:34 richard Exp $
+# $Id: date.py,v 1.30 2002-09-23 07:09:15 richard Exp $
 
 __doc__ = """
 Date, time and time interval handling.
@@ -215,25 +215,25 @@ class Date:
         return str
 
     def set(self, spec, offset=0, date_re=re.compile(r'''
-            (((?P<y>\d\d\d\d)-)?((?P<m>\d\d?)-(?P<d>\d\d?))?)? # yyyy-mm-dd
-            (?P<n>\.)?                                         # .
-            (((?P<H>\d?\d):(?P<M>\d\d))?(:(?P<S>\d\d))?)?      # hh:mm:ss
-            (?P<o>.+)?                                         # offset
+            (((?P<y>\d{4}-)?((?P<m>\d\d?)-(?P<d>\d\d?))?)? # yyyy-mm-dd
+            (?P<n>\.)?                                     # .
+            (((?P<H>\d?\d):(?P<M>\d\d))?(:(?P<S>\d\d))?)?  # hh:mm:ss
+            (?P<o>.+)?                                     # offset
             ''', re.VERBOSE), serialised_re=re.compile('''
-            (\d{4})(\d{2})(\d{2})(\d{2})(\d{2})(\d{2})
-            ''')):
+            (\d{4})(\d\d)(\d\d)(\d\d)(\d\d)(\d\d)
+            ''', re.VERBOSE)):
         ''' set the date to the value in spec
         '''
         m = serialised_re.match(spec)
-        if m:
+        if m is not None:
             # we're serialised - easy!
             self.year, self.month, self.day, self.hour, self.minute, \
-                self.second = map(int, m.groups()[1:7])
+                self.second = map(int, m.groups()[:6])
             return
 
         # not serialised data, try usual format
         m = date_re.match(spec)
-        if not m:
+        if m is None:
             raise ValueError, _('Not a date spec: [[yyyy-]mm-dd].'
                 '[[h]h:mm[:ss]][offset]')