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


Le 05/05/13 04:19, Rob Stewart a écrit :
> On May 4, 2013, at 4:15 PM, "Vicente J. Botet Escriba" <vicente.botet_at_[hidden]> wrote:
>
>
>> I have just extracted from my current interface some of the functions that we could have in a full featured date class.
>>
>> class date;
>>
>> date today();
> I'd expect to be able to influence the time zone.
Boost.DateTime provides time zone management, but as far as I know it
has been a nightmare to maintain it.
If someone knows of some portable 3pp library that we could include in
Boost helping on time zone management I could include it, but developing
it is not on my priorities.
Maybe someone wants to do it or mentor a GSoC for the next year.

The best I can do for the time been is to provide UTC and local
timezones. This doesn't mean that the standard could not provide more.

>> class date {
>> public:
>> // construct/copy/destruct
>> date(); // |year(0)/jan/1|
>> date(year, month, day);
>> date(year, month, day, no_check_t);
>> // and all the usual combinations
> I'm warming up to the checked/unchecked dichotomy between date and make_date(), though the latter can be used for multiple date types and all must be checked or unchecked alike.
>
>> bool set_if_valid_date(year, month, day);
> This seems odd. I'd prefer set(), with an exception and, maybe, try_set(), returning bool.
Yes, the name is not the best. try_set would be better.
>
>> day day() const; // or explict operator day(); the same for the other accessors.
> I'd expect one or the other. day() is probably better, since day can offer an explicit, converting constructor to get the effect of the operator. That simplifies the date I/F a little.
>
Let me show the usage:

dt.day()

or

day(dt)

What do you prefer? Couldn't both be provided?

I have one possible non-member addition. I'm trying to see how to
compare two dates of different date types.
Should the user convert explicitly before comparing ?

days_date d1;
ymd_date d2;

if (d1 == days_date(d2))

versus

if (ymd_date(d1) == d2)

or should the operator choose the conversion?

if (d1 == d2)

This is surely not too important as the user would use the same date
type while comparing comparing dates.

Best,
Vicente