Skip to content

machine.RTC.init documentation is incorrect #5733

Description

@dhylands

The machine.RTC documentation has some discrepancies.

The ESP8266 machine.RTC modules doesn't appear to have an init function, but rather has a datetime function.

STATIC mp_obj_t pyb_rtc_datetime(size_t n_args, const mp_obj_t *args) {

The order of the arguments to datetime appears to be (year, month, day, wday, hour, minute, seconds, milliseconds)

The ESP32 machine.RTC module

STATIC mp_obj_t machine_rtc_datetime_helper(mp_uint_t n_args, const mp_obj_t *args) {

has an init function and a datetime function. The order of the arguments for datetime and init appears to be (year, month, day, hour, minute, seconds, microseconds)

The stm32 machine.RTC module forwards to pyb.RTC

mp_obj_t pyb_rtc_datetime(size_t n_args, const mp_obj_t *args) {

which has an init function and datetime function, but the init function doesn't take any srguments. The datetime function appears to use the order (year, month, day, wday, hour, month, seconds, microseconds)

The documentation documents an init function with arguments in a different order to any of the above and doesnt't mention a datetime function.

And the EPS8266 appears to take milliseconds as the last argument, whereas the others take microseconds.

Activity

  1. dhylands commented on Mar 7, 2020

    @dhylands
    ContributorAuthor

    I think that the documentation should be updated to reflect the code, but I thought I would raise this issue to discuss that before submitting a PR.

  2. peterhinch commented on Mar 8, 2020

    @peterhinch
    Contributor

    See #5553

  3. robert-hh commented on May 20, 2021

    @robert-hh
    Contributor

    Just came along the same mess while implementing a machine.RTC module for mimxrt. It seem the only port using rtc.now() is the cc3200 one, which is stale. So I went for rtc.datetime().

  4. evilhamsterman commented on Oct 18, 2022

    @evilhamsterman

    This is still messed up. The Raspberry Pi Pico doesn't have a init() function, also the wday in RTC.datetime((year, month, day, wday, hour, month, seconds, microseconds)) seems unneeded, it isn't used in any other place and it is something that can be calculated)

  5. peterhinch commented on Oct 18, 2022

    @peterhinch
    Contributor

    You don't need wday when setting time but it is useful when reading it, and it makes sense to use the same tuple for read and write.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions