|
15 | 15 | # BASIS, AND THERE IS NO OBLIGATION WHATSOEVER TO PROVIDE MAINTENANCE, |
16 | 16 | # SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS. |
17 | 17 | # |
18 | | -# $Id: date.py,v 1.29 2002-09-23 06:48:34 richard Exp $ |
| 18 | +# $Id: date.py,v 1.30 2002-09-23 07:09:15 richard Exp $ |
19 | 19 |
|
20 | 20 | __doc__ = """ |
21 | 21 | Date, time and time interval handling. |
@@ -215,25 +215,25 @@ def pretty(self): |
215 | 215 | return str |
216 | 216 |
|
217 | 217 | def set(self, spec, offset=0, date_re=re.compile(r''' |
218 | | - (((?P<y>\d\d\d\d)-)?((?P<m>\d\d?)-(?P<d>\d\d?))?)? # yyyy-mm-dd |
219 | | - (?P<n>\.)? # . |
220 | | - (((?P<H>\d?\d):(?P<M>\d\d))?(:(?P<S>\d\d))?)? # hh:mm:ss |
221 | | - (?P<o>.+)? # offset |
| 218 | + (((?P<y>\d{4}-)?((?P<m>\d\d?)-(?P<d>\d\d?))?)? # yyyy-mm-dd |
| 219 | + (?P<n>\.)? # . |
| 220 | + (((?P<H>\d?\d):(?P<M>\d\d))?(:(?P<S>\d\d))?)? # hh:mm:ss |
| 221 | + (?P<o>.+)? # offset |
222 | 222 | ''', re.VERBOSE), serialised_re=re.compile(''' |
223 | | - (\d{4})(\d{2})(\d{2})(\d{2})(\d{2})(\d{2}) |
224 | | - ''')): |
| 223 | + (\d{4})(\d\d)(\d\d)(\d\d)(\d\d)(\d\d) |
| 224 | + ''', re.VERBOSE)): |
225 | 225 | ''' set the date to the value in spec |
226 | 226 | ''' |
227 | 227 | m = serialised_re.match(spec) |
228 | | - if m: |
| 228 | + if m is not None: |
229 | 229 | # we're serialised - easy! |
230 | 230 | self.year, self.month, self.day, self.hour, self.minute, \ |
231 | | - self.second = map(int, m.groups()[1:7]) |
| 231 | + self.second = map(int, m.groups()[:6]) |
232 | 232 | return |
233 | 233 |
|
234 | 234 | # not serialised data, try usual format |
235 | 235 | m = date_re.match(spec) |
236 | | - if not m: |
| 236 | + if m is None: |
237 | 237 | raise ValueError, _('Not a date spec: [[yyyy-]mm-dd].' |
238 | 238 | '[[h]h:mm[:ss]][offset]') |
239 | 239 |
|
|
0 commit comments