-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathCalendarHelperFunctions.py
More file actions
45 lines (28 loc) · 1.02 KB
/
CalendarHelperFunctions.py
File metadata and controls
45 lines (28 loc) · 1.02 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
from MET import MetDict
def duration(start, end):
[sdate, stime] = start.split('T')
[edate,etime] = end.split('T')
startList = stime.split('-')[0].split(':')
smin = float(startList[0])*60.0+float(startList[1])
endList = etime.split('-')[0].split(':')
emin = float(endList[0])*60.0+float(endList[1])
delta = emin-smin
return delta
def calsBurned(summary, time, person):
if MetDict.has_key(summary) :
met = MetDict[summary]
return time*met*person.weight/200.0
else:
return 0.0
def eaten(eventsList):
cals = 0
for pair in eventsList:
summaryList = pair[0].split(":")
if ( len(summaryList)==2 and(summaryList[0].lower() == "ate")):
cals += float(summaryList[1])
return cals
def burned(eventsList, person):
cals = 0
for pair in eventsList:
cals += calsBurned(pair[0], pair[1], person)
return cals