On 10/14/10 17:01 CDT, Jonathan M Davis wrote:
What's really annoying is when you want to create a range which iterates over
time points which are apart by some combination of years, months, and smaller
units.

The more I think of it the more I want this feature out. It would be borderline nice if it were a natural consequence of the design, but sweating over it doesn't sit well at all.

Before, you could just give the function something like Dur.years(5) +
Dur.months(1) + Dur.days(2) and it would produce a function which gave you a
time point 5 years, 1 month, and 2 days after the previous one. But without
MonthDuration or JointDuration, that becomes much more awkward. I'm still
ironing out the best way to deal with the function signature for that.

I could say

d.addYear(5);
d.addMonths(1);
d.addDays(2);

This is acceptable considering that it's not that often you really need to be 5 years, 1 month, and 2 days from now. Besides it's weird. What if I take 27 January 2010 and then skip that duration? Will I be on Feb 28 2015 or Mar 1 2015? I don't know, and the simple fact that I need to ask myself (and that the library needs to respond) such an awkard question is embarrassing.

If it were me I'd even postulate that addMonths takes you to the 1st of the landing month. Or eliminate addMonths and addYears altogether, because adding 1 year to 29 February 2008 does not land on a good date. Allow the user to construct a new Date from the current year, month, and day.


Andrei
_______________________________________________
phobos mailing list
[email protected]
http://lists.puremagic.com/mailman/listinfo/phobos

Reply via email to