Instead of being an explicit field, it's now a slot like all the other
methods.
This is a marginal code size improvement because most types have a make_new
(100/138 on PYBV11), however it improves consistency in how types are
declared, removing the special case for make_new.
Signed-off-by: Jim Mussared <jim.mussared@gmail.com>
Changes in this commit:
- Start the RTC Timer at system boot. Otherwise time.time() will advance
only if an RTC() object was created.
- Set the time to a more recent date than Jan 1, 1970, if not set. That is
2013/10/14, 19:53:11, MicroPython's first commit.
- Compensate an underflow in in timeutils_seconds_since_2000(), called by
time.time(), if the time is set to a pre-2000 date.
The supplied value for microseconds in datetime() will be treated as a
starting value for the reported microseconds. Due to internal processing
in setting the time, there is an offset about 1 ms.
This change moves the datetime tuple format back to the one used by all the
other ports:
(year, month, day, weekday, hour, minute, second, microsecond)
Weekday is a number between 0 and 6, with 0 assigned to Monday. It has to
be provided when setting the RTC with datetime(), but will be ignored on
entry and calculated when needed.
The weekday() method was removed, since that is now again a part of the
datetime tuple.
The now() method was updated so it continues to return a tuple that matches
CPython's datetime module.
Initial version, using the LP RTC clock. It provides setting the date and
time with rtc.init() or rtc.datetime(), and reading the date and time with
rtc.datetime() or rtc.now(). The method weekday() reports the weekday of
the current date. It starts with 0 for Monday.
The tuple order for datetime() and now() matches the CPython sequence:
(year, month, day, hour, minute, second, microsecond, TZ). TZ is ignored
and reported as None. Microsecond is provided at a best effort.
If a battery is not supplied, the default boot date/time is 1970/1/1 0:0:0.
With a battery, the clock continues to run even when the board is not
powered. The clock is quite precise. If not, using rtc.calibration() may
help.