__TIME__ not set properly

Hi,
According to the doc, the macros __DATE__ and __TIME__ should be initialized with the time when the binary has been compiled.

As much as __DATE__ is set correctly, ```TIME``` seems to be set with GMT-6 instead of my local time, which is CET.

Is there a way to set that correctly under vscode ?

code:

  DateTime compiled(__DATE__, __TIME__); 
  printf("%u/%u/%02u %2u:%02u:%02u\n\r",dt.month(),dt.day(),dt.year(),(dt.hour()-6),dt.minute(),dt.second());

Thanks.

L.

Please share a link.

here is the link:

__DATE__

This macro expands to a string constant that describes the date on which the preprocessor is being run. The string constant contains eleven characters and looks like "Feb 12 1996" . If the day of the month is less than 10, it is padded with a space on the left.

If GCC cannot determine the current date, it will emit a warning message (once per compilation) and __DATE__ will expand to "??? ?? ????" .

__TIME__

This macro expands to a string constant that describes the time at which the preprocessor is being run. The string constant contains eight characters and looks like "23:59:01" .

In my case, the compiler ran at 1pm but __TIME__ is set to 7am.

L.

How about UNIX_TIME variable from PlatformIO Build System? You can use it with build_flags = -DTIME=$UNIX_TIME in platformio.ini.

Nice :slight_smile:

Thanks for the suggestion.