Boost logo

Boost :

Subject: Re: [boost] [date_time] quarters as new durations?
From: Jeff Garland (azswdude_at_[hidden])
Date: 2009-12-22 07:40:33


Stewart, Robert wrote:
> Thomas Lemm wrote:
>> I am happily using the boost date_time library and I plan to
>> extend it towards including quarters as new (gregorian) date
>> durations, just the way months are included already
>> (excluding parsing of quarters)
>
> Why excluding parsing? That would imply only partial support relative to other durations, right?
>
>> What are the chances that his change might make it into the
>> boost date_time library?
>
> Jeff Garland will need to answer that.
>
>> Is there some interest in this feature, if so I would
>> provide a patch to update source and documentation to include
>> the quarters as a new duration.
>
> I think it would be a great addition.

Well, so quarters turns out to be like months as far as durations go -- that
is, it's mathematical like days and weeks. So the big drawback you face is
dealing with the associated "fuzzy math". For example, what's the result of
   date("2008-Feb-28") + quarters(1) = ?
   date("2008-Feb-27") + quarters(1) = ?
Month durations play some games to handle this problem (see docs for details)
which quarters could adopt. But if you adopt the month rules than I don't
thing you buy much more than simply writing

   const months quarters = months(3);

There's also an argument against adding quarters as a duration. I have an app
somewhere in which I have quarter defined as a date_period so I could write:

    date_period q = quarter(2009, 1);

To me at least this seems like the more likely application.

Jeff


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