diff options
author | Alexander Belopolsky <alexander.belopolsky@gmail.com> | 2010-06-14 18:33:19 (GMT) |
---|---|---|
committer | Alexander Belopolsky <alexander.belopolsky@gmail.com> | 2010-06-14 18:33:19 (GMT) |
commit | 97958cf3f872b95500932da9ac354fac894ce1d2 (patch) | |
tree | 6383e9cdd6cd688a4c3b51a6f164fd5c38157e13 /Lib | |
parent | 43ca710a440b02ee38d04e46cf744e1fb9a86634 (diff) | |
download | cpython-97958cf3f872b95500932da9ac354fac894ce1d2.zip cpython-97958cf3f872b95500932da9ac354fac894ce1d2.tar.gz cpython-97958cf3f872b95500932da9ac354fac894ce1d2.tar.bz2 |
Undo r81988 code change leaving added test.
Diffstat (limited to 'Lib')
-rw-r--r-- | Lib/calendar.py | 11 |
1 files changed, 8 insertions, 3 deletions
diff --git a/Lib/calendar.py b/Lib/calendar.py index a82b21a..0c1fdad 100644 --- a/Lib/calendar.py +++ b/Lib/calendar.py @@ -587,12 +587,17 @@ def formatstring(cols, colwidth=_colwidth, spacing=_spacing): EPOCH = 1970 -_EPOCH_DATETIME = datetime.datetime(EPOCH, 1, 1) -_SECOND = datetime.timedelta(seconds=1) +_EPOCH_ORD = datetime.date(EPOCH, 1, 1).toordinal() + def timegm(tuple): """Unrelated but handy function to calculate Unix timestamp from GMT.""" - return (datetime.datetime(*tuple[:6]) - _EPOCH_DATETIME) // _SECOND + 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 def main(args): |