[phobos] next release
Yao G.
yao.gomez at gmail.com
Thu Sep 16 17:09:04 PDT 2010
On Thu, 16 Sep 2010 17:39:19 -0500, Sean Kelly <sean at invisibleduck.org>
wrote:
> 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?
Sean.
I've been porting the Boost date_time library to D. But I have been busy
these last weeks and it's on hold. In essence, is finished, but I need to
add unit test and more documentation, specially to the time module. The
library is huge: I had to use three modules (core.d, date.d and time.d).
In the time.d module is the TimeDuration struct. But right now, as I did
an almost straight port, is somewhat inefficient (at least to use it as a
measure element for the runtime), for two reasons:
1. The resolution is in nanoseconds, meaning that the operations to
calculate the times uses big numbers
2. Internally, it uses a special struct to emulate (+/-) infinity and NAD
(not a date) so most of the time operations are delegated to this struct.
Maybe you can take something from these modules, instead of reimplement
it, and just adapt it or refactor it to make it more efficient. Here's the
code:
> http://bitbucket.org/gomez/yao-library/src/tip/src/yao/datetime/core.d
> http://bitbucket.org/gomez/yao-library/src/tip/src/yao/datetime/date.d
> http://bitbucket.org/gomez/yao-library/src/tip/src/yao/datetime/time.d
And some (incomplete) documentation in pretty looking html:
> http://d.yao.com.mx/datetime/core.html
> http://d.yao.com.mx/datetime/date.html
> http://d.yao.com.mx/datetime/time.html
The documentation of TimeDuration:
> http://d.yao.com.mx/datetime/time.html#TimeDuration
--
Yao G.
More information about the phobos
mailing list