Boost logo

Boost :

From: Jeff Garland (jeff_at_[hidden])
Date: 2002-03-11 23:12:22

All -

I have uploaded a second GDTL submission which now includes both a gregorian
date system and a time system as well. The time system has nano-second
resolution with no built in adjustments for time zones or leap seconds. I
expect we will eventually add other time systems that handle these adjustments.
However the current library should cover a wide variety of applications and will
be plenty to review.

Here are some usage examples from the docs:

using namespace gregorian;
using namespace posix_time;
date d(2002,Feb,1); //an arbitrary date
ptime t1(d, hours(5)+nanosec(100));//date + time of day offset
ptime t2 = t1 - minutes(4)+seconds(2);
ptime now = second_clock::local_time(); //use the clock
//Get the date part out of the time
date today =;
date tommorrow = today + date_duration(1);
ptime tommorrow_start(tommorrow); //midnight tommorrow

//starting at current time iterator adds by one hour
time_iterator titr(now,hours(1));
for (; titr < tommorrow_start; ++titr) {
   std::cout << to_simple_string(*titr) << std::endl;

//convert a utc time to a local time using the TZ settings of the machine
typedef gdtl::local_adjustor<ptime> local_adj;
ptime t10(date(2002,Jan,1), hours(7)); //the utc time
ptime t11 = local_adj::utc_to_local(t10);

The files including extensive test programs and examples can be found here:

The package includes an overview documentation page, but most of the
documentation remains online at:

As for compilers, this code has compiled and tested against BCC5.1.1, gcc3.0.3
Linux, gcc2.95-3 cygwin, and gcc2.95.3 Linux. MSVC7 RC2 has some errors in utc
to local conversion templates, but is mostly ok. MSVC6 is likely similar to
MSVC7 based on experience with previous versions.


Boost list run by bdawes at, gregod at, cpdaniel at, john at