W
W. eWatson
I have two dates, ts1, ts2 as below in the sample program. I know the clock
drift in seconds per day. I would like to calculate the actual date of ts2.
See my question at the end of the program.
# time differences with addition of drift
from datetime import datetime, timedelta
import time
drift = 4.23 # seconds per day
format = '%Y%m%d_%H%M%S'
ts1 = "20080901_120000" # base date-time
ts2 = "20080904_180000"
d1 = datetime(*(time.strptime(ts1, format)[0:6]))
d2 = datetime(*(time.strptime(ts2, format)[0:6]))
#d += timedelta(seconds=sec)
delta = d2-d1
# delta format is nnn[n] days, hh:mm:ss
# delta is type 'datetime.timedelta'
print delta
# get back to ts2 as a check
d3 = d1+d
print d3
#OK, now I need to add the total drift time between
# d1 and d2, to get the true date-time of d2.
# How do I get at the nnn and hh:mm:ss of delta so that
# I can change nnn to nnn+(fraction of day in hh:mm:ss) to
# days + fraction of day, D. I want to multiple D by drift
# to get seconds of drift in period, then add it to d2.
Results
3 days, 6:00:00
2016-09-04 18:00:00
--
W. eWatson
(121.015 Deg. W, 39.262 Deg. N) GMT-8 hr std. time)
Obz Site: 39° 15' 7" N, 121° 2' 32" W, 2700 feet
Web Page: <www.speckledwithstars.net/>
drift in seconds per day. I would like to calculate the actual date of ts2.
See my question at the end of the program.
# time differences with addition of drift
from datetime import datetime, timedelta
import time
drift = 4.23 # seconds per day
format = '%Y%m%d_%H%M%S'
ts1 = "20080901_120000" # base date-time
ts2 = "20080904_180000"
d1 = datetime(*(time.strptime(ts1, format)[0:6]))
d2 = datetime(*(time.strptime(ts2, format)[0:6]))
#d += timedelta(seconds=sec)
delta = d2-d1
# delta format is nnn[n] days, hh:mm:ss
# delta is type 'datetime.timedelta'
print delta
# get back to ts2 as a check
d3 = d1+d
print d3
#OK, now I need to add the total drift time between
# d1 and d2, to get the true date-time of d2.
# How do I get at the nnn and hh:mm:ss of delta so that
# I can change nnn to nnn+(fraction of day in hh:mm:ss) to
# days + fraction of day, D. I want to multiple D by drift
# to get seconds of drift in period, then add it to d2.
Results
3 days, 6:00:00
2016-09-04 18:00:00
--
W. eWatson
(121.015 Deg. W, 39.262 Deg. N) GMT-8 hr std. time)
Obz Site: 39° 15' 7" N, 121° 2' 32" W, 2700 feet
Web Page: <www.speckledwithstars.net/>