I want to calculate the time difference between the epoch and a date in the future, mktime gives an error (OverflowError: mktime argument out of range) if the year is 3001 or higher (on certain OS). I would like to be able to enter up to the year 9999.
for the line:
time_sec = time.mktime(event_date.timetuple())
what else can I use to overcome the overflow error, and still be correct to local time?
My code so far is:
import datetime
import time
yr= 3001
mth = 12
day = 4
start_time = 8
event_date = datetime.datetime(yr, mth, day, int(start_time))
time_sec = time.mktime(event_date.timetuple())
t= time.localtime()
time_frm_epoch = time.mktime(t)
time_remain = time_sec - time_frm_epoch # return false if time_remain < 0
print(time_remain)
Would really appreciate any advice!