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: Not able to change the EPOCH from 1900 to 1970 for the localtime function (time.h)

Part Number: TMS320F28335


Hi,

I am using localtime inbuilt function to convert Unix time stamp into tm structure.

As written in the thread

"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

the EPOCH can be changed from 1900 to 1970 by defining "-D__TI_TIME_USES_64".

This is somehow not working for my setup:

Compiler: 21.6.0.LTS

SYS/BIOS: 6.83.0.18

When I pass the value "1456822873ULL" (should be Tue Mar 01 2016 09:01:13 GMT+0000) to the function "localtime" of "time.h" I get the value "116" for the variable "tm_year" in the tm structure.

I expect the value "46" because of the EPOCH 1970.

I have defined "-D__TI_TIME_USES_64".

Thanks in advance for your support!

Regards,

Matthias

  • Matthias,

    Our compiler expert is out until mid next week.  I will see if I can find someone to help with this.  Could you send snippet of code where you are doing this?

    Regards,

    John

  • When I build without defining __TI_TIME_USES_64 I see a year of 46.  When I build with __TI_TIME_USES_64 I see 116.  Be sure the invocation of the compiler is similar to ...

    "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=tmu0 --vcu_support=vcu0 --include_path="C:/ti/ccs1110/ccs/tools/compiler/ti-cgt-c2000_21.6.0.LTS/include" --include_path="C:/ti/ccs1110/ccs/tools/compiler/ti-cgt-c2000_21.6.0.LTS/lib/src" --define=__TI_TIME_USES_64 -g --diag_warning=225 --diag_wrap=off --display_error_number --abi=coffabi --preproc_with_compile --preproc_dependency="main.d_raw" "../main.c"

    Carefully note how __TI_TIME_USES_64 is defined on the command line.

    Thanks and regards,

    -George

  • Hi George,

    Thanks for your answer!

    I see the same behavior on my system.

    I only was confused because in the link above they said that the POSIX epoch (1970) is used when  __TI_TIME_USES_64 is defined.

    That is now working for me with the property that "tm_year" is returning the years since 1900 and not since 1970 (like it is in your example). This feels a bit inconsistent.

    Regards,

    Matthias

  • "tm_year" is returning the years since 1900 and not since 1970

    The standards for C define that tm_year contains the number of years since 1900.  This is true without regard to the epoch.

    Thanks and regards,

    -George