|
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.68.2.4 2004-10-08 00:34:58 richard Exp $ |
| 18 | +# $Id: date.py,v 1.68.2.5 2005-01-03 03:08:37 richard Exp $ |
19 | 19 |
|
20 | 20 | """Date, time and time interval handling. |
21 | 21 | """ |
@@ -361,8 +361,14 @@ def pretty(self, format='%d %B %Y'): |
361 | 361 | Note that if the day is zero, and the day appears first in the |
362 | 362 | format, then the day number will be removed from output. |
363 | 363 | ''' |
364 | | - str = time.strftime(format, (self.year, self.month, self.day, |
365 | | - self.hour, self.minute, int(self.second), 0, 0, 0)) |
| 364 | + # Python2.4 strftime() enforces the non-zero-ness of the day-of-year |
| 365 | + # component of the time tuple, so we need to figure it out |
| 366 | + t = (self.year, self.month, self.day, self.hour, self.minute, |
| 367 | + int(self.second), 0, 0, 0) |
| 368 | + t = calendar.timegm(t) |
| 369 | + t = time.gmtime(t) |
| 370 | + str = time.strftime(format, t) |
| 371 | + |
366 | 372 | # handle zero day by removing it |
367 | 373 | if format.startswith('%d') and str[0] == '0': |
368 | 374 | return ' ' + str[1:] |
|
0 commit comments