[phobos] next release

Steve Schveighoffer schveiguy at yahoo.com
Fri Sep 17 11:08:54 PDT 2010





----- Original Message ----
> From: Jonathan M Davis <jmdavisProg at gmx.com>
> To: phobos at puremagic.com
> Sent: Thu, September 16, 2010 7:27:21 PM
> Subject: Re: [phobos] next release
> 
> On Thursday, September 16, 2010 15:39:19 Sean Kelly wrote:
> > On Sep 9,  2010, at 5:25 PM, Jonathan M Davis wrote:
> > > Just so you know, I fully  expect that the datetime code that I've been
> > > working on will be  done in less than a month. It'll be at least a week
> > > (probably  closer to two), but it certainly won't be in the range of a
> > > month.  Now, how many changes will be required after it's reviewed, or
> > >  whether it will be accepted at all, is another matter. But it shouldn't
> >  > be all that much longer before I'm done.
> > 
> > There are a bunch  of routines in druntime that could really use a
> > structured timespan  representation (Boost actually even uses a full
> > SystemTime class for  most of these) and I'm trying to work out the best
> > way to do this.   In Tango, the decision was to have the routines all
> > accept a long value  that is the same resolution as the tick count from
> > TimeSpan, which is  why everything currently works as it does.  I've always
> > hated this  and would love to do something more structured, but
> > complications arise  from possible redundancy or incompatibility with
> > std.time.  What  I've done for now is duplicate Boost's time_duration
> > struct (as  TimeDuration) into core.time, and I'm looking at using this for
> >  Thread.sleep(), etc.  Thoughts?
> >  _______________________________________________
> > phobos mailing  list
> > phobos at puremagic.com
> >  http://lists.puremagic.com/mailman/listinfo/phobos
> 
> For what I've done, I  have an enum of possible time units : year, month, week, 
>
> day, hour, second,  minute, second, millisecond, microsecond,  and tick (where 
>a 
>
> tick is  100 nanoseconds). I then have a Duration struct which is templatized 
>on 
>
> the  time unit enum and takes a value. So, you end up with a Duration which 
>which 
>
> has a value (which is a long) and a type of time unit (e.g. 10 seconds or  1000 
>
> days). All of the functions that take a Duration are templatized so  they will 

> take any Duration with units that they're compatible with (the  main problem 
>with 
>
> making them compatible with _all_ time units being that  you cannot convert 
> between years or months and any other units without a  specific date because 
>the 
>
> number of days in a month is not  consistent).

I don't see the point of doing this.  If you just say the Duration is not 
templated, and defines a number of ticks, you get a 20,000 year span.  Is that 
not enough span?  It just seems like its unnecessarily complicated.  Now if I 
want to add two Durations together and one is in seconds and the other is in 
milliseconds, I have to generate a new function because it's templated.  It's 
trivial to get the number of seconds from a number of ticks, if that's what you 
are interested in.

-Steve



      


More information about the phobos mailing list