[phobos] datetime review

Jonathan M Davis jmdavisProg at gmx.com
Thu Oct 14 18:26:58 PDT 2010


On Thursday 14 October 2010 18:04:03 Steve Schveighoffer wrote:
> ----- Original Message ----
> 
> > From: Jonathan M Davis <jmdavisProg at gmx.com>
> > 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. 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.
> 
> If that's all it is then why can't you specify both a month term and a
> Duration term to the range constructor:
> 
> // range takes a Duration, and optional Months type (wrapper for N months
> for the type system).
> auto r = myInterval.range(days(2), years(5) + months(1));
> 
> Yes it looks a bit awkward, but it's a very specific need, and not a very
> common one (IMO).

There are various options. It's just that it gets to be a bit long on the 
parameter list and dealing with AllowDayOverflow in the best manner isn't 
entirely straightforward. So, it's quite doable. The question is the best way to 
do it cleanly. And I haven't had the chance to spend much time on it yet to sort 
that out. It's on my TODO list for this evening.

- Jonathan M Davis


More information about the phobos mailing list