Charles Hixson
11/23/2003 7:38:00 PM
David Garamond wrote:
> I'm looking for a 64bit timestamp definition/standard with suitable
> range (at least from year 1900 to 2100) and precision (at least
> milliseconds). So far .NET's System.DateTime is the best candidate
> (range is year 1 AD to 9999 AD, precision is 0.1 microsecond).
> However, conversion to/from UNIX timestamp looks to be
> non-straightforward. Is there a Ruby library to do this (or to/from
> other suitable timestamp)?
>
> I could always invent my own timestamp, but...
Given that:
1 Year = 365.25 days 365 days/year
1 Day = 24 hours 8,766 hours/year
1 Hour = 60 minutes 525,960 minutes/year
1 Minute = 60 seconds 31,557,600 seconds/year
1 Second = 1000 miliseconds 31,557,600,000 ms/year
1 ms = 10 .1 ms 315,576,000,000 .1 ms/year
2 ^ 63 = 9,223,372,036,854,780,000 => 29,227,102 years @ .1 ms
So just pick a good date... say 00:00:00.0000001 01/01/2000 and figure
forwards and backwards from there. Even specifying 0.01 ms resolution
shouldn't hurt you for most purposes. (Actually I meant New Years +
epsilon at Greenwich on the year 2000 CE). But the birthday of Charles
Babbage would be just as good, except for things like the problem of
figuring leap seconds. Since very few people need to worry about leap
seconds I think you can leave worrying about the details required to
handle them until later. Just provide some reasonable way to add in a
table of fudge factors.