Boost logo

Boost Users :

From: Jeff Garland (jeff_at_[hidden])
Date: 2003-06-27 09:23:49


> Here's a list of a few things I find unelegant in the date_time
> package:
>
> 1. Order or parameters
>
> Consider these declarations:
>
> date d(year, month, day);
> partial_date pd(day, month);
>
> So date() uses month before day, while partial_date() uses day
> before month.

Yes, this was recently changed. The reason is that partial_date is a date generator
like 'first_kday_after' (eg: 'First Monday in January') and I was able to write
time adjustment code more cleanly by keeping he month as the second parameter in
all date generators.
 
> 2. No += and -=
>
> I can say
> date1 = date1 + date_duration(3);
> but not
> date1 += date_duration(3);

Good point. Apparently we aren't using boost::operators aggressively enough
here. I'll put it on the todo list.

> 3. Namespace problems
>
> Date generators are in different namespaces: Both partial_date and
> first_kday_of_month are found in boost::date_time, but partial_date
> is also carried over in boost::gregorian, whereas
> first_kday_of_month is not.

Fixed in CVS. All the generators are now available in boost::gregorian.

> 4. Inconsistent abbreviations
>
> If I want the first Thursday in September, I must write:
>
> boost::date_time::first_kday_of_month<date> fts(Thursday, Sep);
>
> 'Thursday' must not be abbreviated to 'Thu'.
> 'Sep' must not be unabbreviated to 'September'.

True. If you really need this you can just update boost/date_time/date_defs.hpp
to the way you want it.

> 5. Misleading exception string
>
> This code:
> try {
> date d(2003, Feb, 29);
> }
> catch (std::out_of_range exc) {
> std::cout << "Caught exception: "
> << exc.what() << std::endl;
> }
>
> surprisingly outputs this text:
>
> Caught exception: Day of month value is out of range 1..31
>
> So, it seems that 29 is not in the range 1..31.

Fixed in CVS. Now you will get "Day of month is not valid for year"
instead.

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