[phobos] std.datetime and tick types
Jonathan M Davis
jmdavisProg at gmx.com
Tue Sep 28 00:39:35 PDT 2010
On Monday 27 September 2010 22:08:12 Robert Jacques wrote:
> On Mon, 27 Sep 2010 11:51:00 -0400, Jonathan M Davis <jmdavisProg at gmx.com>
> Well, if you make up a unit, then you can guarantee no one will have heard
> of it before. And really, learning the hecto SI prefix means someone will
> always understand what hectonanosecond means, as opposed to StdTick or
> Duration, etc, which would have a tendency to be quickly forgotten or
> confused with another library type from another language. As for typing, I
> would expect the 100ns unit to be mainly an internal thing. Most of the
> time I deal in microseconds/1000.0 (i.e. floating point milliseconds),
> when dealing with std.perf today.
Well, it's not entirely made up. 100ns is the tick that Windows uses. So, I
believe that it's used in C# and other Windows-centric code. So, there is a
precedent. And while ticks/hectonanoseconds are mostly internal, there are
certain operations where you're going to want to use them, albeit hopefully
fairly rarely. The documentation does use the term quite a bit though,
particularly since std ticks pretty much replace time_t - though that can be a
bit confusing because time_t is a type which holds the number of milliseconds
since midnight January 1st, 1970 while std ticks are unit of time which are 100
ns and are used to hold the time from midnight January 1st, 1 AD.
Maybe, I should replace some of the mentios of ticks with something like StdTime
(would be an alias for long and hold units of 100 ns with midnight January 1st,
1 AD as its epoch) and use hectonanosecond where its an issues of units rather
than type.
Bleh. I don't entirely like any of the options. Having StdTime does seem like a
good idea, since it does help properly separate the idea of the unit and a type
with those units from the epoch, but I really don't like hectonanoseconds. It's
just way too long. milliseconds and microseconds are already seriously pushing
it. Hectonanoseconds do have the virtue of being explicit however. Some people
will know what they mean (though I wouldn't expect very many people to), and
those who don't probably wouldn't have known what ticks indicated anyway, though
the few people that I've talked to about it haven't liked the idea of having
hectonanoseconds, since it's really ugly.
- Jonathan M Davis
More information about the phobos
mailing list