rtc — Real Time Clock

The rtc module provides support for a Real Time Clock. It also backs the time.time() and time.localtime() functions using the onboard RTC if present.

Libraries

rtc.set_time_source(rtc)

Sets the rtc time source used by time.localtime(). The default is rtc.RTC().

Example usage:

import rtc
import time

class RTC(object):
    @property
    def datetime(self):
        return time.struct_time((2018, 3, 17, 21, 1, 47, 0, 0, 0))

r = RTC()
rtc.set_time_source(r)