dscohen dscohen - 4 months ago
1311 0

Simple tracker for watches



import time
import datetime
import os

if not os.path.exists('time_log.txt'):
    f = open('time_log.txt','w')
    f = open('time_log.txt','a')
    t = time.time()
    f.write(str(t)+' '+str(t))

with open('time_log.txt','r') as fh:
    for line in fh:
    last = line
sys_time,last_watch_time = map(float,last.split())

hhmmss = raw_input('Enter Input:\n')
[hours, minutes, seconds] = [int(x) for x in hhmmss.split(':')]
date = datetime.date.today()
date = datetime.datetime(date.year,date.month,date.day,hours,minutes,seconds)
watch_time = time.mktime(date.timetuple())

current_time = time.time()

print ('your watch is {0} seconds fast from UTC').format(watch_time-current_time)
print ('your watch is {0} seconds diff from last measure').format(last_watch_time+(current_time-sys_time)-watch_time)
watch_time_diff = last_watch_time+(current_time-sys_time)-watch_time
percentage =watch_time_diff * 1/((current_time-sys_time)/(24*60*60))
print ('your watch is expected to deviated {0} seconds/24hours').format(percentage)

with open('time_log.txt','a') as fh:
    fh.write('\n'+str(current_time)+ ' '+str(watch_time))