Boost logo

Boost :

Subject: Re: [boost] [gsoc 2013] draft proposal for chrono::date
From: Vicente J. Botet Escriba (vicente.botet_at_[hidden])
Date: 2013-05-03 03:47:39

Le 03/05/13 05:46, Rob Stewart a écrit :
> On May 2, 2013, at 5:35 PM, Anurag Kalia <anurag.kalia_at_[hidden]> wrote:
>> Rob Stewart-6 wrote
>> That is the only reason I am antagonist to otherwise completely natural
>> construction of:
>> date natural = day(7) / month(12) / year(2013);
> That will be harder to optimize. I'm not saying that it wouldn't be optimized, just harder, so less likely. It's also unlike anything in the standard.
You are right. This expression should be included a s SHOULD feature,not
a MUST feature.
The constructor of a date must provide almost the same functionality and
even more. E.g. my days_date has the following constructors

   days_date(year, month, day);
   days_date(year::rep, month::rep, day::rep, no_check_t);
   days_date(year, month_day);
   days_date(year::rep, month_day, no_check_t);
   days_date(year, day_of_year);
   days_date(year::rep, day_of_year::rep, no_check_t);
   explicit days_date(days);
   days_date(days, no_check_t);
   days_date(days::rep, no_check_t);
   days_date(year::rep, month::rep, day::rep, bool, no_check_t);

And all my date classes have the same constructors.
> I don't think that's any clearer than this:
> date d(7, dec, year(2013))
> (The months can be from an enumerated type.)
> One can specify a day or year object and avoid ambiguity:
> date(unsigned, month, year);
> date(day, month, unsigned);
I would add the following constructors
   days_date(year, month, day::rep);
   days_date(year, month::rep, day);
   days_date(year::rep, month, day);
   days_date(year::rep, month_day);
   days_date(year, day_of_year);
   days_date(year::rep, day_of_year);
   days_date(year, day_of_year::rep);

> You can even handle other orders that way:
> date(month, unsigned, year);
> date(month, day, unsigned);
> date(unsigned, day, month);
> date(year, unsigned, month);
> One can also be explicit for both day and year:
> date(year, month, day);
> date(month, day, year);
> date(day, month, year);
> date(day, year, month);
I don't think that the constructor should support different orderings.
> (That last seems particularly odd, but could be supported.)
> I'm assuming explicit constructors for day and year, of course.
Of course. And implicit conversion to his representation, so that

   date(2013, may, 3, no_check)

is yet valid.

We could have a factory make_date function that doesn't checks the
validity of the date and avoids the no_check parameter

   make_ymd_date(2013, may, 3)


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