std.date proposal
Walter Bright
newshound at digitalmars.com
Mon Apr 3 11:42:50 PDT 2006
Fredrik Olsson wrote:
> 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.
Double has another problem when used as a date - there are embedded
processors in wide use that don't have floating point hardware. This
means that double shouldn't be used in core routines that are not
implicitly related to doing floating point calculations.
A time/date package should pick one representation for time, and stick
with it. Other representations should be supported only by converting
them back and forth to the one format.
More information about the Digitalmars-d-announce
mailing list