[phobos] datetime review

Andrei Alexandrescu andrei at erdani.com
Sun Oct 10 21:36:13 PDT 2010


On 10/10/10 15:10 CDT, Yao G. wrote:
> On Sat, 09 Oct 2010 23:23:37 -0500, Andrei Alexandrescu
> <andrei at erdani.com> wrote:
>
>> On 10/9/10 20:40 CDT, Denis wrote:
>>> I believe in D one should be able to write a RangedInt(int lowerBound,
>>> int upperBound) type
>>
>> More precisely: BoundedInt(long lowerBound, ulong upperBound) so it
>> can express any range of any number.
>>
>> Andrei
>
> This is an example, ported from the Boost date time library:
>
> http://bitbucket.org/gomez/yao-library/src/tip/src/yao/datetime/core.d#cl-551

Do you plan to submit this to Phobos? Then it needs a fair amount of work.

- Need support for unsigned numbers

- Need support for floating-point numbers

- The behavior of the limits is odd - why does IntWrapped!(int, 1, 10) 
cover [0, 9] and not [1, 10]?

- Limits are adjusted in a Procrustean manner, they should be enforced 
instead (at least for the Bounded type being discussed)

- asNumber should be exposed as alias this.

- add, subtract etc. should be operators

- Many other functions need to be added


Andrei


More information about the phobos mailing list