This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

[参考译文] TMS320F28335:无法将 localtime 函数的 epoch 从1900更改为1970 (time.h)

Guru**** 2535150 points


请注意,本文内容源自机器翻译,可能存在语法或其它翻译错误,仅供参考。如需获取准确内容,请参阅链接中的英语原文或自行翻译。

https://e2e.ti.com/support/microcontrollers/c2000-microcontrollers-group/c2000/f/c2000-microcontrollers-forum/1108565/tms320f28335-not-able-to-change-the-epoch-from-1900-to-1970-for-the-localtime-function-time-h

器件型号:TMS320F28335

您好!

我正在使用 localtime 内置函数将 Unix 时间戳转换为 TM 结构。

如线程中所写的那样

" https://e2e.ti.com/support/tools/code-composer-studio-group/ccs/f/code-composer-studio-forum/493367/c2000-cgt-15-x-y-time-h-changes/1785188?tisearch=e2e-sitesearch&keymatch=c2000%252520localtime#1785188

通过定义"-D_TI_TIME_USS_64"、可以将 epoch 从1900年更改为1970年。

这在某种程度上不适用于我的设置:

编译器:21.6.0.LTS

SYS/BIOS:6.83.0.18

当我将值"1456822873ULL"(应为 Tue Mar 01 2016 09:01:13 GMT+0000)传递到"time.h"的函数"localtime"时、我会获得 TM 结构中变量"TM_year "的值"116"。

因为1970年代、我希望值为"46"。

我已定义 "-D__TI_TIME_USS_64"。

提前感谢您的支持!

此致、

Matthias

  • 请注意,本文内容源自机器翻译,可能存在语法或其它翻译错误,仅供参考。如需获取准确内容,请参阅链接中的英语原文或自行翻译。

    Matthias、

    我们的编译器专家将于下周中旬结束。  我将会看到我是否可以找到人来帮助解决这个问题。  您能否将代码片段发送到您要执行此操作的位置?

    此致、

    John

  • 请注意,本文内容源自机器翻译,可能存在语法或其它翻译错误,仅供参考。如需获取准确内容,请参阅链接中的英语原文或自行翻译。

    当我在不定义_TI_TIME_USS_64的情况下进行编译时、我看到一年为46。  当我使用_TI_TIME_USS_64进行编译时、我会看到116。  请确保调用编译器类似于...

    "c:/ti/ccs1110/ccs/tools/compiler/ti-cgt-C2000-21.6.0.LTs/bin/cl2000"-v28 -ml -mt --cla_support=cla2 -float_support=fpu32 -tmu_support=tmu_vcu_support=vcu-inctr_board_boards/pred_transc/board.htm-boards/prob_display_boards/prob_display-board.trusers-board_guides=c2000-rema-board.tr-board.trab-board_guest/cc10.htm_guid_guest_guides/c2000-real-board.tr_guides/ctr-board.tr_guides/ctr-board_guides=t.tr-tr-board_guides=d_guest_tr-d_guides=d_guides_guides/c2000-real-ines_tr-tr-tr.tr.tr.tr.tr.tr.tr.inc.tr.tr.tr.inc_guides/ctr.inc

    请仔细注意 如何 在命令行上定义__TI_TIME_USes_64。

    谢谢、此致、

    乔治

  • 请注意,本文内容源自机器翻译,可能存在语法或其它翻译错误,仅供参考。如需获取准确内容,请参阅链接中的英语原文或自行翻译。

    尊敬的乔治:

    感谢您的回答!

    我在我的系统上看到相同的行为。

    我之所以感到困惑、是因为在上面的链接中、他们说在  定义_TI_TIME_USS_64时使用 POSIX epoch (1970)。

    现在、这对我来说是一个很好的属性、"TM_year "是指从1900年而不是1970年(就像您的例子中那样)之后的年份。  这感觉有点不一致。

    此致、

    Matthias

  • 请注意,本文内容源自机器翻译,可能存在语法或其它翻译错误,仅供参考。如需获取准确内容,请参阅链接中的英语原文或自行翻译。
    [引用 userid="180176" URL"~/support/microcontrollers/C2000-microcontrollers-group/CC2000/f/C2000-microcontrollers-forume/1108565/TMS320F28335-low-able to change-epoch from -1900-to -1970-for-the -localtime-functional-time-h/4113594#41chines'、自1900"1900年起不再引用"14000"、[#13594TM"年后]

    C 的标准定义 TM_year 包含1900年以来的年数。  无论时代如何,都是如此。

    谢谢、此致、

    乔治