AnsweredAssumed Answered

How to calculate date,month and year ?

Question asked by H.Rick on Jan 8, 2014
Latest reply on Jan 9, 2014 by Clive One
Guys,

How to calculate date,month and year ? from RTC_GetCounter function,

I saw :

uint32_t RTC_GetCounter(void)
{
  uint16_t tmp = 0;
  tmp = RTC->CNTL;
  return (((uint32_t)RTC->CNTH << 16 ) | tmp) ;
}
I've done :
 /* Load the Counter value */
 Tmp = RTC_GetCounter();

 /* Load the Counter value */
 Tmp = RTC_GetCounter();

 /* Compute day */
 WEEKDAY = (Tmp / 86400)%7;

 /* Compute date */
 DATE = (Tmp / 86400)%360;


/* Compute month */
 MONTH = (Tmp / 2629743)%12;

 

 /* Compute year */
YEAR = (Tmp / 31556926)+1970;
Please correct me .....
Any clues ?
thanks

Outcomes