-
Notifications
You must be signed in to change notification settings - Fork 9
/
time_helper.py
38 lines (29 loc) · 861 Bytes
/
time_helper.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
#!/usr/bin/env python3
# -*- coding: UTF-8 -*-
"""
Time Helper
Sync and set internal clock (RTC) with NTP server time
"""
from machine import RTC
# import ntptime
import time
class TimeHelper(object):
"""docstring for TimeHelper"""
def __init__(self, tz: int = 1):
"""
Initialize TimeHelper
:param tz: Timezone offset
:type tz: int, optional
"""
self.rtc = RTC()
self._timezone = tz
def sync_time(self, timezone: int = None) -> None:
"""
Sync the RTC with data from NTP server.
No network check is performed.
Existing RTC value will not be changed if NTP server is not reached.
No daylight saving is implemented.
:param timezone: The timezone shift
:type timezone: int, optional
"""
pass