Boost logo

Boost Users :

From: Jeff Garland (jeff_at_[hidden])
Date: 2007-11-12 22:19:46


Christoph wrote:
> Is there special support in Boost.Date_Time to support quarters, or (just)
> years?

There isn't anything to support quarters, but it would be pretty easy to roll
your own. There is a year type called greg_year.

> Consider the following scenario: I have a customer (or patient) whose
> (exact) date of birth is not known, only that 'he was born in 1960' or
> in 'May 1960' (w/o attached information on month or days).

You could combine greg_year and greg_month....it's a bit inefficient. It
turns out a whipped up a month_year for someone else once, but it never got
into the library. Here's what the user code looks like:

   month_year my1(2006, Feb);
   std::cout << my1 << std::endl;
   month_year my3 = my1 - months(2);
   month_year my4 = my3 - years(2);
   my3 -= months(1);
   if (my1 <= my3 ) {...}

   months m = my1 - my3;
   std::cout << "month diff: " << m.number_of_months() << std::endl;
   date d(2007,Feb, 22);
   month_year my5(d);

If this is what you need, I could post it or send it to you.

> Is there another way to handle this (and preserve knowledge about the
> incomplete information) besides pretending that month (and perhaps even
> day) is 1 and storing additional flags about the information being not
> actually present?

I've also written a time type for measurements that carried along error
information with it. You could do the same thing with dates, but it's not
well documented how to do this and you'd have to work out issues of what to do
with arithmetic and such. But I'm afraid it's not in date-time 'out of the box'.

Jeff


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