[phobos] datetime review

Andrei Alexandrescu andrei at erdani.com
Sat Oct 9 15:34:41 PDT 2010


On 10/9/10 17:22 CDT, Simen Kjaeraas wrote:
> Andrei Alexandrescu <andrei at erdani.com> wrote:
>>> assert( convert!years( months( 24 ) ) == 2 );
>>
>> This would be the case if we go with separate types for duration units
>> (years, months,...), but not if we use long throughout.
>
> Or if months() is a function returning the appropriate long.

I see. So years() and months() would return a long that is internally 
understood to represent a specific unit for the interval.

By the way there's a disconnect at the junction between weeks and months 
due to the day-in-a-month irregularity, which the docs mention too.

So, three options:

a) long+conventions all the way

b) one type per duration notion (year, month, week, ..., second, hnsecond)

c) one unified type of duration that serves as an intermediary for all 
conversions. So getting the years from months would go months -> unified 
duration -> years.

Currently the library is very undecided and does a bit of which. We 
should simplify and go with one all the way.


Andrei


More information about the phobos mailing list