RTC_BASE_YEAR cannot be overridden

Report here problems in any of ChibiOS components. This forum is NOT for support.
steved
Posts: 825
Joined: Fri Nov 09, 2012 2:22 pm
Has thanked: 12 times
Been thanked: 135 times

RTC_BASE_YEAR cannot be overridden

Postby steved » Wed Mar 15, 2023 2:31 pm

RTC_BASE_YEAR is set to 1980 in hal_rtc.h, and used in hal_rtc.c [rtcConvertDateTimeToStructTm() and rtcConvertStructTmToDateTime()] to calculate an offset in years from the start of 1980.
A consequence of this is that the year field in the TOD clock is 20 years ahead, which gives scope for confusion.
Maybe this was intentional; however the RP2040 RTC driver looks as if it might store the year as is.

There do seem to be some wider consequences to attempting to redefine RTC_BASE_YEAR (e.g. FAT filesystem time stamp calculations, and the start date for UNIX time stamps), so maybe any handling of the 20-year offset should be in the individual LLDs.

For now I've put this aside; might try and offer a patch later (depends how frustrated I get explaining to forgetful others why the "raw" year is out by 20!)

User avatar
Giovanni
Site Admin
Posts: 14455
Joined: Wed May 27, 2009 8:48 am
Location: Salerno, Italy
Has thanked: 1076 times
Been thanked: 922 times
Contact:

Re: RTC_BASE_YEAR cannot be overridden

Postby Giovanni » Wed Mar 15, 2023 4:46 pm

Hi,

LLD are meant to do adjustments, the 1980 as base year is only the external representation. Do you see a better approach?

Giovanni

steved
Posts: 825
Joined: Fri Nov 09, 2012 2:22 pm
Has thanked: 12 times
Been thanked: 135 times

Re: RTC_BASE_YEAR cannot be overridden

Postby steved » Thu Mar 16, 2023 9:36 am

Giovanni wrote:LLD are meant to do adjustments, the 1980 as base year is only the external representation. Do you see a better approach?

Not in this specific case - I agree that LLDs are the place to do the adjustment, but didn't make it very clear. Really putting up a marker for any new stuff. And perhaps highlighting that, where possible, there should be close correlation between high level data and its low-level representation (on any LLD).


Return to “Bug Reports”

Who is online

Users browsing this forum: No registered users and 37 guests