AnsweredAssumed Answered

Why does MQX 3.8.1 time_from_date() fail for any date in 1995?

Question asked by Wayne Taylor on Apr 21, 2015
Latest reply on Apr 22, 2015 by Radek Sestak

It turns our that time_from_date() and time_to_date(), both use a look-up table, _time_secs_before_year_internal[], to convert years to seconds since 1970. If you open "\Freescale MQX 3.8\mqx\source\kernel\ti_rom.c" you will find that 1995 has been entered as 1996. There are two entries for 1996 and no entry for 1995.

 

   ((1994UL-1970UL) * SECS_IN_YEAR) + ( 6UL * SECS_IN_DAY),

   ((1996UL-1970UL) * SECS_IN_YEAR) + ( 6UL * SECS_IN_DAY),

   ((1996UL-1970UL) * SECS_IN_YEAR) + ( 6UL * SECS_IN_DAY),

 

So to fix this problem, replace 1996UL with 1995UL and recompile libraries.

 

Cheers,

 

Wayne

Outcomes