Boost logo

Boost Users :

From: Claus Tondering (yg-boost-users_at_[hidden])
Date: 2003-06-27 02:15:17


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.

2. No += and -=

   I can say
        date1 = date1 + date_duration(3);
   but not
        date1 += date_duration(3);

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.

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'.

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.

--
Claus Tondering

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