std.date proposal
Fredrik Olsson
peylow at treyst.se
Thu Mar 30 00:53:48 PST 2006
Frank Benoit skrev:
> Timestamp is double.
> I don't think a date dependent precision is good choice.
> I vote for
>
> /**
> Nanosecondes since 1/1/2000
> */
> public typedef long d_timestamp;
>
> This is enough for +-270 Years and has an accuracy which is good enough
> for me :)
>
I see your point, and will try to explain why I have chosen double as I
have.
Using double I get the same scale for dates for timestamps, as for
dates; the integer part is days.
Having dates a days with times as fractions is also how the astronomers
do it, they call it Julian Days, and base it on monday, january 1, 4713
BCE as the epoch. But the idea is the same.
It is datatype used by many database implementations (PostgreSQL, MySQL,
MS SQL Server 7 (and beyond?)).
A double can represent infinity, -infinity, and not a number can be not
a date.
+-270 years is sort of an limitation :), even a simple genealogy
application would hit that limit quite soon. Using a double is based on
the idea that the farther away from today, the less relevant is precision.
// Fredrik
More information about the Digitalmars-d-announce
mailing list