Search code examples
c++timezonecross-platformace

How to get a local time instead of UTC time in ACE?


I've been using the ACE_OS::gettimeofday() in a program to get the current time. From what I know, ACE always use UTC internally. However, sometimes I do need to convert the UTC time to a local time based on the system's timezone.

Is it possible to do this conversion without using any platform-specific technique? Any suggestion would be appreciated.


Solution

  • @ArunMu

    By some googling, which follows your answer of course, I found the following solution, thanks!

    time_t temptime = ACE_OS::gettimeofday().sec();
    
    tm* timeinfo = ACE_OS::localtime(&temptime); // local time
    
    tm* timeinfo = ACE_OS::gmtime(&temptime);    // UTC/GMT time