cancel
Showing results for 
Search instead for 
Did you mean: 

STM32F4 RTC - leap year

sascha23
Associate II
Posted on September 08, 2016 at 13:16

Hi,

when i use the RTC, which year i have to set due to the leap year compensation? There are just two BCD digits for the year so i have to save the start/offset year in code?

If now would be the year 2015. Do i have to set the year i the RTC module to 3 and save the offset 2012? Is year 0 a leap year in the RTC calendar? I can not find any definition in the reference manual.

Thanks

3 REPLIES 3
slimen
Senior
Posted on September 08, 2016 at 15:58

Hi,

Leap year occurs every four years, in years which are multiples of 4. For example, 2012was a leap year.

An exception to that is any year which is a multiple of 100. For example,the year 2100 is not a leap year. A further exception is that years which are multiples of 400are indeed leap years. Hence, while 2100 is not a leap year, 2400 is.

Regards

Walid FTITI_O
Senior II
Posted on September 08, 2016 at 16:32

Hi neumann.sascha,

As mentionned is the reference manua ; Part of ''Real-time clock'' , both leap year and 30-31 day months are managed automatically by the RTC state machine.

''Compensations for 28-, 29- (leap year), 30-, and 31-day months are performed automatically. Daylight saving time compensation can also be performed.''

 

-Hannibal-

Posted on September 08, 2016 at 16:52

The RTC can't calculate day-of-week, and is probably Julian, thus it does not need to know the century. Your application would need to perform a correction in the date/day of week three times in every 400 years, first time in 1. March 2100.

JW