[phobos] datetime review
Jonathan M Davis
jmdavisProg at gmx.com
Mon Oct 11 10:12:07 PDT 2010
On Sunday, October 10, 2010 08:16:52 Jonathan M Davis wrote:
> On Sunday 10 October 2010 07:45:14 Andrei Alexandrescu wrote:
> > Again, the action item is to find realistic use cases.
>
> Really, the only major case that I can think of is that being able to
> generate arbitrary durations is useful when dealing with ranges. If you're
> simply trying to add a duration to a time point, it's not much worse to
> have to explicitly use addYears and/or addMonths in addition to adding a
> duration to the time point (a bit annoying perhaps, but not a big deal).
> Generic code also does better with durations (though we could always keep
> addTUnit() and that would solve the generic code issue just fine), but I
> question that that's all that big a deal.
It looks like dealing with some of the interval functions such as shift() and
expand() is definitely more pleasant with durations which can hold months and
years, but versions of them can be added which take years and months instead.
Looking at it, I think that having just a duration which holds hnsecs internally
will simplify the library a fair bit and make learning it easier and less
overwhelming but will be at least somewhat frustrating to anyone who's really
trying to use some of its more advanced features. However, that bit of extra
pain for those types of folks is likely heavily outweighed by the benefits to the
more casual user.
Of course, if we drop intervals as Andrei suggested, then functions like shift()
and expand() won't matter anymore (since they won't exist), but I'm not sure
that we want to drop that functionality.
- Jonathan M Davis
More information about the phobos
mailing list