2014-05-04 07:40:51 -04:00
|
|
|
import pyb
|
2014-05-03 11:43:27 -04:00
|
|
|
from pyb import RTC
|
2014-05-04 07:40:51 -04:00
|
|
|
|
2014-05-03 11:43:27 -04:00
|
|
|
rtc = RTC()
|
|
|
|
print(rtc)
|
2014-05-10 06:56:58 -04:00
|
|
|
|
|
|
|
# make sure that 1 second passes correctly
|
2014-05-03 11:43:27 -04:00
|
|
|
rtc.datetime((2014, 1, 1, 1, 0, 0, 0, 0))
|
2014-08-16 08:39:14 -04:00
|
|
|
pyb.delay(1001)
|
2014-05-03 11:43:27 -04:00
|
|
|
print(rtc.datetime()[:7])
|
2014-05-10 06:56:58 -04:00
|
|
|
|
|
|
|
def set_and_print(datetime):
|
|
|
|
rtc.datetime(datetime)
|
|
|
|
print(rtc.datetime()[:7])
|
|
|
|
|
|
|
|
# make sure that setting works correctly
|
|
|
|
set_and_print((2000, 1, 1, 1, 0, 0, 0, 0))
|
|
|
|
set_and_print((2000, 1, 31, 1, 0, 0, 0, 0))
|
|
|
|
set_and_print((2000, 12, 31, 1, 0, 0, 0, 0))
|
|
|
|
set_and_print((2016, 12, 31, 1, 0, 0, 0, 0))
|
|
|
|
set_and_print((2016, 12, 31, 7, 0, 0, 0, 0))
|
|
|
|
set_and_print((2016, 12, 31, 7, 1, 0, 0, 0))
|
|
|
|
set_and_print((2016, 12, 31, 7, 12, 0, 0, 0))
|
|
|
|
set_and_print((2016, 12, 31, 7, 13, 0, 0, 0))
|
|
|
|
set_and_print((2016, 12, 31, 7, 23, 0, 0, 0))
|
|
|
|
set_and_print((2016, 12, 31, 7, 23, 1, 0, 0))
|
|
|
|
set_and_print((2016, 12, 31, 7, 23, 59, 0, 0))
|
|
|
|
set_and_print((2016, 12, 31, 7, 23, 59, 1, 0))
|
|
|
|
set_and_print((2016, 12, 31, 7, 23, 59, 59, 0))
|
|
|
|
set_and_print((2099, 12, 31, 7, 23, 59, 59, 0))
|