[Patches] [ python-Patches-658405 ] use datetime for calendar.py
noreply@sourceforge.net
noreply@sourceforge.net
Wed, 25 Dec 2002 00:18:53 -0800
Patches item #658405, was opened at 2002-12-25 02:29
You can respond by visiting:
https://sourceforge.net/tracker/?func=detail&atid=305470&aid=658405&group_id=5470
Category: Library (Lib)
Group: Python 2.3
Status: Open
>Resolution: Accepted
Priority: 5
Submitted By: Raymond Hettinger (rhettinger)
>Assigned to: Raymond Hettinger (rhettinger)
Summary: use datetime for calendar.py
Initial Comment:
Straightforward update for calendar.py to use the
datetime module instead of the time module.
Simplifies the code, makes it more readable, and
dramatically extends the range of usable dates.
----------------------------------------------------------------------
>Comment By: Tim Peters (tim_one)
Date: 2002-12-25 03:18
Message:
Logged In: YES
user_id=31435
Good idea! Random comments:
+ The old "Revision 2" comment was useless in the code
and belonged in a checkin comment. The same for the
new "Revision 3" comment.
+ leapdays() should be changed to use integer division (//
instead of /)
+ timegm() could be similarly simplified:
EPOCH = 1970 # that's already there
_EPOCH_ORD = datetime.date(EPOCH, 1, 1).toordinal()
def timegm(tuple):
# Replace all the code computing days by
days = datetime.date(year, month, day).toordinal() -
_EPOCH_ORD
The assertions can be dropped too, as the date()
constructor does a better of job of checking them than the
timegm() code is doing.
----------------------------------------------------------------------
You can respond by visiting:
https://sourceforge.net/tracker/?func=detail&atid=305470&aid=658405&group_id=5470