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

取消
显示结果 
显示  仅  | 搜索替代 
您的意思是: 
已解决

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

跳至解决方案
887 次查看
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

标记 (1)
0 项奖励
回复
1 解答
819 次查看
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 项奖励
回复
1 回复
820 次查看
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 项奖励
回复