root/snippets/wakeup/wakeup.py

Revision 13, 0.8 kB (checked in by hey, 10 months ago)

기상시각 통계

  • Property svn:executable set to *
Line 
1#!/usr/bin/python
2
3def timeToInt((hour,minute)):
4    if 12<hour: hour-=24
5    return hour+minute/60.0
6
7def intToTime(time):
8    hour=int(time)
9    return hour,int(round((time-hour)*60))
10
11
12def processTime(time):
13    return timeToInt([int(e) for e in time.split(':')])
14
15def averageTime(times):
16    total=0
17    for i in times: total+=i
18    return intToTime(total/len(times))
19
20sleep=[]
21wakeup1=[]
22wakeup2=[]
23insleep=[]
24
25for i in file('WakeUpLog.txt').readlines():
26    times = i.split('||')
27    sleep.append(processTime(times[0]))
28    wakeup1.append(processTime(times[2]))
29    wakeup2.append(processTime(times[1]))
30    insleep.append(processTime(times[2])-processTime(times[0]))
31
32print averageTime(sleep)
33print averageTime(wakeup1)
34print averageTime(wakeup2)
35print averageTime(insleep)
Note: See TracBrowser for help on using the browser.