[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

comp.lang.ruby

64bit timestamp library

David Garamond

11/23/2003 1:30:00 PM

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

--
dave




5 Answers

T. Onoma

11/23/2003 1:41:00 PM

0

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. ;)

On Sunday 23 November 2003 02:29 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...



Charles Hixson

11/23/2003 7:38:00 PM

0

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.



David Garamond

11/23/2003 8:19:00 PM

0

Charles Hixson 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
[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).

--
dave



David Garamond

11/23/2003 8:23:00 PM

0

T. Onoma wrote:
> 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/l...


> On Sunday 23 November 2003 02:29 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...

--
dave




Josef 'Jupp' Schugt

11/24/2003 1:14:00 PM

0

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
--
.-------.
message > 100 kB? / | |
sender = spammer? / | R.I.P.|
text = spam? / ___| |___