Boost logo

Boost Users :

Subject: [Boost-users] [date-time] Getting time from midnight in nanoseconds
From: ppatel_at_[hidden]
Date: 2010-10-22 09:48:43


I am resending this with proper subject line.

Thanks

From: Priyank Patel
Sent: Friday, October 22, 2010 8:47 AM
To: boost-users_at_[hidden]
Subject: Getting time from midnight in nanoseconds

Hi,

Can you please tell me if there is a way to get current time in nanoseconds using boost date_time library?
I have tried following but it doesn't seems to be returning values in nanoseconds. I know I have used microsec_clock and that might be the problem but not sure what alternate to use.
Any help will be appreciated.

hrtime_t getCurrentTime() {
    boost::posix_time::ptime recvTime = boost::posix_time::microsec_clock::local_time();
    boost::posix_time::time_duration duration( recvTime.time_of_day() );
    return duration.total_nanoseconds(); // This call returns values in microseconds (last three digits are always zero in returned value)
}

Thanks
Priyank



Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net