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

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

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

Jump to solution
364 Views
waynetaylor
Contributor II

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

Tags (1)
0 Kudos
1 Solution
296 Views
RadekS
NXP Employee
NXP Employee

Thank you for your bug report.

You are right it is obvious bug.

I check that this bug was in MQX up to MQX 4.0.2.2 version (time_tables.c file).

Since MQX 4.1.0, _time_secs_before_year_internal[] table is not part of MQX code.

I hope it helps you.

Have a great day,
RadekS

-----------------------------------------------------------------------------------------------------------------------
Note: If this post answers your question, please click the Correct Answer button. Thank you!
-----------------------------------------------------------------------------------------------------------------------

View solution in original post

0 Kudos
1 Reply
297 Views
RadekS
NXP Employee
NXP Employee

Thank you for your bug report.

You are right it is obvious bug.

I check that this bug was in MQX up to MQX 4.0.2.2 version (time_tables.c file).

Since MQX 4.1.0, _time_secs_before_year_internal[] table is not part of MQX code.

I hope it helps you.

Have a great day,
RadekS

-----------------------------------------------------------------------------------------------------------------------
Note: If this post answers your question, please click the Correct Answer button. Thank you!
-----------------------------------------------------------------------------------------------------------------------

0 Kudos