comparison roundup/date.py @ 3029:145cd31e258b maint-0.7

merge from HEAD
author Richard Jones <richard@users.sourceforge.net>
date Mon, 03 Jan 2005 03:08:37 +0000
parents 8a4a2e135a73
children
comparison
equal deleted inserted replaced
3027:5fb65feb8944 3029:145cd31e258b
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.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 """Date, time and time interval handling. 20 """Date, time and time interval handling.
21 """ 21 """
22 __docformat__ = 'restructuredtext' 22 __docformat__ = 'restructuredtext'
23 23
359 ''' print up the date date using a pretty format... 359 ''' print up the date date using a pretty format...
360 360
361 Note that if the day is zero, and the day appears first in the 361 Note that if the day is zero, and the day appears first in the
362 format, then the day number will be removed from output. 362 format, then the day number will be removed from output.
363 ''' 363 '''
364 str = time.strftime(format, (self.year, self.month, self.day, 364 # Python2.4 strftime() enforces the non-zero-ness of the day-of-year
365 self.hour, self.minute, int(self.second), 0, 0, 0)) 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 # handle zero day by removing it 372 # handle zero day by removing it
367 if format.startswith('%d') and str[0] == '0': 373 if format.startswith('%d') and str[0] == '0':
368 return ' ' + str[1:] 374 return ' ' + str[1:]
369 return str 375 return str
370 376

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