Index: Lib/calendar.py =================================================================== --- Lib/calendar.py (revision 81989) +++ Lib/calendar.py (working copy) @@ -587,17 +587,14 @@ EPOCH = 1970 -_EPOCH_ORD = datetime.date(EPOCH, 1, 1).toordinal() +_EPOCH_DATETIME = datetime.datetime(EPOCH, 1, 1) +_SECOND = datetime.timedelta(seconds=1) - def timegm(tuple): """Unrelated but handy function to calculate Unix timestamp from GMT.""" - year, month, day, hour, minute, second = tuple[:6] - days = datetime.date(year, month, 1).toordinal() - _EPOCH_ORD + day - 1 - hours = days*24 + hour - minutes = hours*60 + minute - seconds = minutes*60 + second - return seconds + return (datetime.datetime(*tuple[:5]) + + datetime.timedelta(seconds=tuple[5]) - + _EPOCH_DATETIME) / _SECOND def main(args):