-
Notifications
You must be signed in to change notification settings - Fork 10
/
helpers.py
44 lines (36 loc) · 893 Bytes
/
helpers.py
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
import ujson
def convert_twenty_four_to_twelve_hour(hour):
if hour <= 12:
return hour
elif hour == 13:
return 1
elif hour == 14:
return 2
elif hour == 15:
return 3
elif hour == 16:
return 4
elif hour == 17:
return 5
elif hour == 18:
return 6
elif hour == 19:
return 7
elif hour == 20:
return 8
elif hour == 21:
return 9
elif hour == 22:
return 10
elif hour == 23:
return 11
def convert_celsius_to_temperature(temp):
return (temp * 1.8) + 32
def read_json_file(filename):
with open(filename) as json_file:
data = ujson.loads(json_file.read())
return data
def write_json_file(filename, json_dict):
json_string = ujson.dumps(json_dict)
with open(filename, "w") as json_file:
json_file.write(json_string)