64bit timestamp library

D

David Garamond

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...
 
T

T. Onoma

Do me a favor and build you own 128bit timestamp and lets be done with these
restraints. I'm getting shades of Y2K mainia all over again. ;)
 
C

Charles Hixson

David said:
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.
 
D

David Garamond

Charles said:
Given that: 1 Year = 365.25 days 365 days/year
[snip]

Thanks for the explanation. I should've completed my previous sentence:
"I could always invent my own timestamp, but... I really don't want to
:)" There are already too many kinds of timestamps out there (MySQL's,
Firebird's, Unix's, PostgreSQL's, Win32's, .NET's, etc).
 
D

David Garamond

T. Onoma said:
Do me a favor and build you own 128bit timestamp and lets be done with these
restraints. I'm getting shades of Y2K mainia all over again. ;)

With 64bit you are quite free to do ranges from thousands of BC to
hundreds of thousands AD with subsecond precision. You don't really need
128bit unless you're doing something like atomic-level time scales (e.g.
picosecond precision) or something like GUID.

But if you want a 128bit timestamp, there's already DJB's libtai:

http://cr.yp.to/libtai.html
 
J

Josef 'Jupp' SCHUGT

Hi!

* Charles Hixson; 2003-11-23, 23:49 UTC:
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

Or, as w physicist would pput it:

2**63 * 0.1 ms = 8 * 10**18 * 0.1 ms = 8 * 10**17 ms
1 yr = PI * 10**7 s = PI * 10**10 ms (1)
PI = 22/7 (2)

8 * 10**17 ms = 8/PI * 10**(17-10) a = 56/22 * 10**7 a = 3 * 10**7 a

(1) Alien but quite precise :->
(2) Any Forth programmers among us?

Josef 'Jupp' Schugt
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
474,141
Messages
2,570,813
Members
47,357
Latest member
sitele8746

Latest Threads

Top