forked from sixfab/sixfab-power-python-api
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathrtc_set.py
More file actions
21 lines (15 loc) · 679 Bytes
/
rtc_set.py
File metadata and controls
21 lines (15 loc) · 679 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
from power_api import SixfabPower, Definition, Event
import time
api = SixfabPower()
epoch = time.time() # to get timestamp in seconds in GMT0
# to get local time on raspberry pi
localtime = time.asctime( time.localtime(time.time()) )
print("Local current time :", localtime)
# to get timezone difference as minus
print(time.timezone)
# standard epoch time with no location specific
print("Epoch Time: " + str(int(epoch)))
# to calculate epoch with respect to local time
# use it for set_rtc_time() function as timestamp (epoch - time.timezone)
print("Epoch Local: " + str(int(epoch) - time.timezone))
print("Result: " + str(api.set_rtc_time(int(epoch) - time.timezone)))