Skip to content

weekday property returns wrong value #4

@hilderic

Description

@hilderic

There's clearly a cut-and-paste error in ds1307.py:

@property
def weekday(self) -> int:
    """
    Get the weekday from the RTC

    :returns:   Weekday of RTC
    :rtype:     int
    """
    return self.datetime[5]

The last line should obviously refer to self.datetime[6] instead; as it is, it's returning the current value of seconds.

However I am also doubtful about the implementation and perhaps even the meaning of the property weekday_start. The docs simply define it as "the start of the weekday". It appears to be used as an offset for translating the chip's day of week numbers 0-6 to another range, e.g., 1-7. However, even a value of 1 can cause datetime to call _bcd_to_dec() with a negative argument, in which case it returns a bogus value. Perhaps I'm missing something, but it looks to me as if it has to remain zero.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions