comparison roundup/date.py @ 3030:d9cc29eee7c5 maint-0.8

merge from HEAD
author Richard Jones <richard@users.sourceforge.net>
date Mon, 03 Jan 2005 03:08:37 +0000
parents ad04cb95e2b0
children 62b1a54107e6
comparison
equal deleted inserted replaced
3026:35c515c072dd 3030:d9cc29eee7c5
13 # BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS 13 # BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
14 # FOR A PARTICULAR PURPOSE. THE CODE PROVIDED HEREUNDER IS ON AN "AS IS" 14 # FOR A PARTICULAR PURPOSE. THE CODE PROVIDED HEREUNDER IS ON AN "AS IS"
15 # BASIS, AND THERE IS NO OBLIGATION WHATSOEVER TO PROVIDE MAINTENANCE, 15 # BASIS, AND THERE IS NO OBLIGATION WHATSOEVER TO PROVIDE MAINTENANCE,
16 # SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS. 16 # SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS.
17 # 17 #
18 # $Id: date.py,v 1.77 2004-11-29 14:32:55 a1s Exp $ 18 # $Id: date.py,v 1.77.2.1 2005-01-03 03:06:30 richard Exp $
19 19
20 """Date, time and time interval handling. 20 """Date, time and time interval handling.
21 """ 21 """
22 __docformat__ = 'restructuredtext' 22 __docformat__ = 'restructuredtext'
23 23
365 ''' print up the date date using a pretty format... 365 ''' print up the date date using a pretty format...
366 366
367 Note that if the day is zero, and the day appears first in the 367 Note that if the day is zero, and the day appears first in the
368 format, then the day number will be removed from output. 368 format, then the day number will be removed from output.
369 ''' 369 '''
370 str = time.strftime(format, (self.year, self.month, self.day, 370 # Python2.4 strftime() enforces the non-zero-ness of the day-of-year
371 self.hour, self.minute, int(self.second), 0, 0, 0)) 371 # component of the time tuple, so we need to figure it out
372 t = (self.year, self.month, self.day, self.hour, self.minute,
373 int(self.second), 0, 0, 0)
374 t = calendar.timegm(t)
375 t = time.gmtime(t)
376 str = time.strftime(format, t)
377
372 # handle zero day by removing it 378 # handle zero day by removing it
373 if format.startswith('%d') and str[0] == '0': 379 if format.startswith('%d') and str[0] == '0':
374 return ' ' + str[1:] 380 return ' ' + str[1:]
375 return str 381 return str
376 382

Roundup Issue Tracker: http://roundup-tracker.org/