Undo r81988 code change leaving added test.
This commit is contained in:
parent
43ca710a44
commit
97958cf3f8
|
@ -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):
|
||||
|
|
Loading…
Reference in New Issue