Given that the accuracy of Windows GetLocalTime (and GetSystemTime) is milliseconds, perhaps a millisec_clock would be better that putting this in the microsec_clock? It would possibly make more sense

Cheers

Russell

Russell Hind wrote:
C++Builder doesn't currently support the microsec_clock of date_time because of its standard library. Would it be possible to add code to get the time using Win32 methods as this gives millisecond times? Something like this in microsec_time_clock.hpp seems to work

    static time_type local_time()
    {
    #ifdef __BORLANDC__
    SYSTEMTIME lt;
        GetLocalTime(&lt);

    date_type d = date_type(lt.wYear,
                            lt.wMonth,
                            lt.wDay);

    int adjust = resolution_traits_type::res_adjust() / 1000;
    time_duration_type td = time_duration_type(lt.wHour,
                                               lt.wMinute,
                                               lt.wSecond,
                                               lt.wMilliseconds * adjust);
        return time_type(d, td);
    #else
    ....
    #endif
    }

Is this Ok, and would it be of interest to anyone? It could be used for all Win32 compilers (if the adjust statement is correct) or are there reasons why platform specific code wouldn't be wanted in the library?

We currently log a lot of error information to text files, but sub-second times are useful. date_time currently doesn't offer this for C++Builder, so that is why we would like something like this added.

Cheers

Russell


_______________________________________________
Unsubscribe & other changes: http://lists.boost.org/mailman/listinfo.cgi/boost




_______________________________________________
Unsubscribe & other changes: http://lists.boost.org/mailman/listinfo.cgi/boost

Reply via email to