Boost logo

Boost Users :

Subject: Re: [Boost-users] [chrono] Initializing system_clock from microseconds
From: Vicente J. Botet Escriba (vicente.botet_at_[hidden])
Date: 2013-06-12 01:44:11


Le 11/06/13 19:15, Kelly, Dan a écrit :
>
> I'm using 1.47, so I would expect this issue to apply. However, I
> don't think this is what I am experiencing.
>
> Right now I am testing out a fix which initially appears to work but I
> have to fully verify it.
>
> voidmy_class::calculate_packet_statistics( conststructpcap_pkthdr
> *header ) {
>
> frame_interval_.intervalTimeStamp_ = system_clock::from_time_t(
> static_cast<time_t>( header->ts.tv_sec ) );
>
> // Cast to a duration using the system_clock's tick period.
>
> system_clock::duration us_duration = duration_cast<
> system_clock::duration >( microseconds( header->ts.tv_usec ) );
>
> frame_interval_.intervalTimeStamp_ += us_duration;
>
> ...
>
> }
>
> I would have thought my previous implementation would have done this
> cast implicitly, but that doesn't appear to be the case. I'll let you
> know if this works.
>
>
What about something like

frame_interval_.intervalTimeStamp_ =
            system_clock::from_time_t( static_cast<time_t>(
header->ts.tv_sec ) ) +
            nanoseconds( header->ts.tv_usec);

Best,
Vicente



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