The documentation says that the RTC clock can be initialized with the RTC.init call.
https://docs.micropython.org/en/latest/esp8266/library/machine.RTC.html
But it does not work that way:
>>>import machine
>>>rtc = machine.RTC()
>>>rtc.init((2018,4,10,17,30))
Traceback (most recent call last):
File "<stdin>", line 1 in <module>:
AttributeError: 'RTC' object has no attribute 'init'
So the documentation contradicts reality. The firmware version is v1.9.3 - downloaded the latest just a few days ago.
Most interestingly, dir(rtc) gives ['datetime','memory','alarm','alarm_left','irq','ALARM0']. It is missing several other methods: now, deinit, cancel
So where is the RTC init method, and how could it disappear?
UPDATE: I have figured out that the documentation is wrong, I need to use RTC.datetime instead of RTC.init. But it is still wrong:
>>>from machine import RTC
>>>rtc=RTC()
>>>rtc.datetime((2000,1,1,23,59,59,0,0))
>>>rtc.datetime()
(2000, 1, 3, 0, 11, 59, 3, 705)
In other words: 2000-01-01T23:59:59 suddenly became 2000-01-03T00:11:59. How?
I also could not find anything useful on the tzinfo parameter of the RTC.datetime method. It should be a number, that is clear. But what does it mean?
I have also tried midnight:
>>>rtc.datetime((2000,1,1,0,0,0,0,0))
>>>rtc.datetime()
(2000,1,1,5,0,0,1,155)
So at tzinfo=0, midnight becomes 05:00:00. I first thought that it means UTC+5 but it does not:
>>>rtc.datetime((2000,1,1,10,0,0,0,0))
>>>rtc.datetime()
(2000,1,1,5,0,0,1,155)
And finally:
>>>rtc.datetime((2000,1,1,5,0,0,0,0))
>>>rtc.datetime()
(2000,1,1,5,0,0,1,545)
This is insane! It looks like the hour part is totally ignored.