jeudi 1 septembre 2016

std::chrono::system_clock::now() considering the OS configured time zone

I´m programming a C++ code that is running on a BusyBox embedded linux. My code and its libraries has several calls to std::chrono::system_clock::now() to get the current time.

Since now my box was configured as dafault time zone (UTC) and everything works fine, processes running and results ok.

Now I had to set my linux to stay in a different timezone. Then I did it by configuring in the box /etc/profile:

export TZ=UTC+3

When I issue date command and the console I get the correct time, but my calls to std::chrono::system_clock::now() I´m still getting the UTC time, not the time that is shown in the date command (the correct time).

I don´t want to change all my now() calls - there are hundreds on them... And that is causing my processes to work with different time than the correct time, set on the console.

IS there any way to solve that without changing my code ? Anything I´m missing here ?

Thanks for helping.

Aucun commentaire:

Enregistrer un commentaire