Boost logo

Boost :

From: Jeff Garland (jeff_at_[hidden])
Date: 2003-09-08 08:55:16


On Mon, 8 Sep 2003 17:03:09 +0200, Bernard wrote

> Bonjour,
> I'm puzzled by the accuracy of date_time library :
> using debian package of boost 1.30.0 on intel Linux, (Resolution:
> Micro -- Ticks per second: 1000000). I can never get a non-zero
> fractional seconds when doing
> boost::posix_time::second_clock::local_time().time_of_day()
> .fractional_seconds()
>
> How is it possible to get precise current time with boost date_time ?

You will need to use the microsecond time clock instead:

    using boost::posix_time;
    ptime now = microsec_clock::local_time();

This isn't fully supported on all platforms yet (mostly windows), but I would
expect it would work fine on debian. You might want to run the test to be sure:

  cd libs/date_time/test
  bjam --verbose-test testmicrosec_time_clock

This test will validate that your clock and library provides a consistently
increasing subsecond values.

Jeff


Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk