[ create a new paste ] login | about

Link: http://codepad.org/aK8hiSUs    [ raw code | output | fork ]

Python, pasted on Mar 26:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
from time import time, mktime
from datetime import datetime, timedelta

# calculate remaining days to the year 2045
ts = time()
print datetime.fromtimestamp(ts).strftime('%Y/%m/%d %H:%M:%S')

ts_xday = mktime(datetime.strptime('2045/1/1', '%Y/%m/%d').timetuple())
delta1 = timedelta(seconds=(ts_xday - ts))
print delta1

# when is the date which 10000 days remain.
ts10000 = ts_xday - timedelta(days=10000).total_seconds()
print datetime.fromtimestamp(ts10000).strftime('%Y/%m/%d')


Output:
1
2
3
4
5
2017/03/26 14:40:06
Traceback (most recent call last):
  Line 8, in <module>
    ts_xday = mktime(datetime.strptime('2045/1/1', '%Y/%m/%d').timetuple())
OverflowError: mktime argument out of range


Create a new paste based on this one


Comments: