|
Boost : |
Subject: Re: [boost] [gsoc 2013] chrono::date
From: Vicente J. Botet Escriba (vicente.botet_at_[hidden])
Date: 2013-04-26 22:42:37
Le 26/04/13 23:43, Anurag Kalia a écrit :
>> One can then, taking the current definition of the civil (gregorian) calendar, create several more units which can be quite useful:
>>
>> There are exactly 7 days in a week:
>>
>> typedef std::chrono::duration
>> <
>> std::int32_t, std::ratio_multiply<days::period, std::ratio<7>>
>>> weeks;
>> There are exactly 146097 days in 400 years, which could rightly be called an era:
>>
>> typedef std::chrono::duration
>> <
>> std::int32_t, std::ratio_multiply<days::period, std::ratio<146097>>
>>> eras;
>> There are exactly 400 years in an era:
>>
>> typedef std::chrono::duration
>> <
>> std::int32_t, std::ratio_divide<eras::period, std::ratio<400>>
>>> years;
>> And there are exactly 12 months in a year:
>>
>> typedef std::chrono::duration
>> <
>> std::int32_t, std::ratio_divide<years::period, std::ratio<12>>
>>> months;
>> Now the definitions of years and months must be understood to be the average length, when converted to other units. But this is not so different than days being 24 hours: this is an average length of a day.
> This is almost magical! This definition of years gives me 43 years as the time since epoch, which is correct! Now given that these units are not the conventional duration of years or months, I don't think we benefit from exposing them to public, do we? Can we use these units in implementation when converting from JDN to Gregorian date?
In Boost.Chrono/Date I named them average_years and average_months.
>
> A user would want to use the construct year to either make a date where it would be an integer, or she/he would want to increment/decrement a date by a certain number of years, where it would be a duration. But we can provide them this functionality using a function and thereby not exposing this approximate year duration. If she/he happens to output an year otherwise, it would print 365.2425 which would only serve to confuse them, no?
No if it know we are talking of average years.
>
>
> Thanks a lot for the support. I have uploaded a draft proposal to this
> Mailing List. Would you kindly check it for me? I am not sure if I
> should upload it twice.
Where the proposal is uploaded?
Best,
Vicente
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk