mirror of
https://github.com/python/cpython.git
synced 2025-12-09 10:37:17 +00:00
Undo r81988 code change leaving added test.
This commit is contained in:
parent
43ca710a44
commit
97958cf3f8
1 changed files with 8 additions and 3 deletions
|
|
@ -587,12 +587,17 @@ def formatstring(cols, colwidth=_colwidth, spacing=_spacing):
|
||||||
|
|
||||||
|
|
||||||
EPOCH = 1970
|
EPOCH = 1970
|
||||||
_EPOCH_DATETIME = datetime.datetime(EPOCH, 1, 1)
|
_EPOCH_ORD = datetime.date(EPOCH, 1, 1).toordinal()
|
||||||
_SECOND = datetime.timedelta(seconds=1)
|
|
||||||
|
|
||||||
def timegm(tuple):
|
def timegm(tuple):
|
||||||
"""Unrelated but handy function to calculate Unix timestamp from GMT."""
|
"""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):
|
def main(args):
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue