IAR <time.h>, localtime, mktime

Viewed 1260

I am using the DLib for your IAR-Compiler and wanted to convert a UTC-timestamp to a local timestamp.

I am located in Germany hence my implementation for the __getzone-method is as followed:

char const * __getzone() {
  return ":GMT+1:GMT+2:0100:(1980)032502+0:102503+0";
}

I wrote some testcode:

time_t ts = 1509238797L;//29.10.2017-02:59:57 3 seconds before dst
struct tm* pre = localtime(&ts);

time_t after = ts + 5L;//wait 5 seconds -> 29.10.2017-02:00:02
struct tm* post = localtime(&after);

The "pre" variable is fine but the "post" variable contains the value: 29.10.2017-03:00:02 but it should be 29.10.2017-02:00:02.

I debugged the code in Visual-Studio and everything seems to work there. Am I missing something?

1 Answers
Related