Re: converting tai64n to something readable

2000-08-19 Thread Russell Nelson

Ben Beuchler writes:
  Yeah, I seem to have a mental glitch lately that tells my fingers to
  type "it's" in all the wrong places.

It's hard to get right.

  I've read the doc you mention.  I found it rather tough to follow.  I
  just received some info from Russ that I think is unlocking my mental
  block for me, so it may make some sense for me by tomorrow.

That would be Allbery, I'm guessticating.

-- 
-russ nelson [EMAIL PROTECTED]  http://russnelson.com  | If you think 
Crynwr sells support for free software  | PGPok | health care is expensive now
521 Pleasant Valley Rd. | +1 315 268 1925 voice | now, wait until you see
Potsdam, NY 13676-3213  | +1 315 268 9201 FAX   | what it costs when it's free. 



Re: converting tai64n to something readable

2000-08-16 Thread Ian Lance Taylor

   Date: Tue, 15 Aug 2000 23:42:18 -0500
   From: Ben Beuchler [EMAIL PROTECTED]

   I've read and reread DjB's documentation of the format and still find it
   quite confusing.  For example, I still do not understand the
   significance of the first eight bytes of the stamp.  I think it is the
   reference point for the second four bytes, but why is it necessary?  Why
   would the reference point change?  Why not select an arbitrary point in
   time and make it the reference point?

tai64n is tai64 followed by a number of nanoseconds.  tai64 is a 64
bit number.  In external format, this is 24 hexadecimal digits.  The
first 16 hex digits are the tai64 portion.  The last 8 hex digits are
the number of nanoseconds.  The web page refers to these 24 hex digits
as 12 bytes--8 bytes for tai64 and 4 bytes for the nanoseconds.

Here is a recent tai64n timestamp: 4000399a2c15230e6f14.  The
tai64 portion is 4000399a2c15.  This is 2^62 + 0x399a2c15.  This
is between 2^62 and 2^63, so this represents the second 0x399a2c15
seconds after the beginning of 1970.  The rest of the timestamp is is
0x230e6f14 == 588148500.  So this tai64n label represents
August 16, 2000 05:52:21.5881485 +

Your questions about the reference point seem to indicate some
confusion.  I'm not sure what you are getting at.  DJB did pick an
arbitrary reference point: he picked January 1, 1970, the same
reference point as is used for the Unix epoch.  The first 8 bytes,
minus 2^62, give the number of seconds since January 1, 1970.  The
last 4 bytes give the number of nanoseconds since the start of that
second.  There are one (American) billion nanoseconds in one second,
so 4 bytes is enough.

   I would also appreciate it if someone could sketch out some pseudo-code
   for working with tai64n.  A task I have frequently wished I could
   perform would be slicing out a section of a log file covering a
   specified time range.  Since I do not know C, I do not have the luxury
   of using libtai.  So I guess I would need a way of converting a specific
   time to it's tai64n equivalent.

Well, here is a trivial way to do that using GNU date, restricted to
times before the year 2038, ignoring nanoseconds:
echo 4000`(echo obase = 16; date +%s) | bc`

Here I use "date +%s" to convert the current time into the number of
seconds since January 1, 1970.  The --date option can be used to pick
any other time.  Then I prepend 4000 to effectively add 2^62, and
I use zeroes to pick out the start of the given second.

Ian



Re: converting tai64n to something readable

2000-08-16 Thread Eric Cox


Ben Beuchler wrote:
 
 Since I do not know C, I do not have the luxury
 of using libtai.  So I guess I would need a way of converting a specific
 time to it's tai64n equivalent.

First, like some people have already said, learn C.  If you ever need to 
write something that handles large amounts of data effeciently on a *nix 
machine, C is the s**t.  Not to mention you may need to modify one of your 
programs to suit your tastes. 

That being said, i'm working on a Python module as an interface to libtai.  
I believe I've figured out most of the intricacies of Python modules, and 
have a few functions coded.  But with my schedule it will be at least a 
few days until I can use it in a program to test it out.  

I'll post a webpage at www.ericcox.com when it does something useful...

Eric



Re: converting tai64n to something readable

2000-08-16 Thread Frank Tegtmeyer

Ben Beuchler wrote:

 of using libtai.  So I guess I would need a way of converting a specific
 time to it's tai64n equivalent.
 
 Thoughts?  Suggestions?

Look at
http://www.lightwerk.com/djbdns/isotai64.c

It generates only external TAI64, but a modification for external TAI64N
could be made with a Perl filter. Simply add the nanoseconds.

Regards, Frank



converting tai64n to something readable

2000-08-15 Thread Ben Beuchler

I know this spawned one of those never-ending threads last time I
brought it up, so I'm not asking for opinions on the usefulness or lack
thereof of the tai64n format.  I'm just trying to *understand* the
format...

I've read and reread DjB's documentation of the format and still find it
quite confusing.  For example, I still do not understand the
significance of the first eight bytes of the stamp.  I think it is the
reference point for the second four bytes, but why is it necessary?  Why
would the reference point change?  Why not select an arbitrary point in
time and make it the reference point?

I would also appreciate it if someone could sketch out some pseudo-code
for working with tai64n.  A task I have frequently wished I could
perform would be slicing out a section of a log file covering a
specified time range.  Since I do not know C, I do not have the luxury
of using libtai.  So I guess I would need a way of converting a specific
time to it's tai64n equivalent.

Thoughts?  Suggestions?

Thanks,
Ben

-- 
Ben Beuchler [EMAIL PROTECTED]
MAILER-DAEMON (612) 321-9290 x101
Bitstream Underground   www.bitstream.net



Re: converting tai64n to something readable

2000-08-15 Thread Chris, the Young One

On Tue, Aug 15, 2000 at 11:42:18PM -0500, Ben Beuchler wrote:
I'm just trying to *understand* the
 format...

http://cr.yp.to/libtai/tai64.html describes TAI64, TAI64N, and TAI64NA.

Since I do not know C, I do not have the luxury
 of using libtai.

Go to your local library and borrow KR. After reading chapter one,
you'll learn most things you need to know. :-)

   So I guess I would need a way of converting a specific
 time to it's tai64n equivalent.

troll
his, her, its; not hi's, he'r, it's
/troll

Sorry Ben, I had to say that. :-) But seriously, look at the URL above.

---Chris K.
-- 
 Chris, the Young One |_ If you can't afford a backup system, you can't 
  Auckland, New Zealand |_ afford to have important data on your computer. 
http://cloud9.hedgee.com/ |_ ---Tracy R. Reed  



Re: converting tai64n to something readable

2000-08-15 Thread Ben Beuchler

On Wed, Aug 16, 2000 at 05:18:50PM +1200, Chris, the Young One wrote:

 http://cr.yp.to/libtai/tai64.html describes TAI64, TAI64N, and TAI64NA.
 
  Since I do not know C, I do not have the luxury
  of using libtai.
 
 Go to your local library and borrow KR. After reading chapter one,
 you'll learn most things you need to know. :-)
 
  So I guess I would need a way of converting a specific
  time to it's tai64n equivalent.
 
 troll
 his, her, its; not hi's, he'r, it's
 /troll
 
 Sorry Ben, I had to say that. :-) But seriously, look at the URL above.

Yeah, I seem to have a mental glitch lately that tells my fingers to
type "it's" in all the wrong places.

I've read the doc you mention.  I found it rather tough to follow.  I
just received some info from Russ that I think is unlocking my mental
block for me, so it may make some sense for me by tomorrow.

I do need to learn at least some C, I know.  So far I have found a
knoledge of Python and some Perl to be more useful. I'm assuming the
"KR" to which you refer is an introductory C text?

Ben

-- 
Ben Beuchler [EMAIL PROTECTED]
MAILER-DAEMON (612) 321-9290 x101
Bitstream Underground   www.bitstream.net



Re: converting tai64n to something readable

2000-08-15 Thread Chris, the Young One

On Wed, Aug 16, 2000 at 12:36:49AM -0500, Ben Beuchler wrote:
 I've read the doc you mention.  I found it rather tough to follow.  I
 just received some info from Russ that I think is unlocking my mental
 block for me, so it may make some sense for me by tomorrow.

I guess I'm not you, but I pretty much got it the moment I read it.
Basically, for a TAI64 label, numbers below 2^62 are ``negative'',
and between 2^62 and 2^63 are ``positive'', relative 19700101 TAI.

That's what the 0x4000 prefix you're seeing stands for.
(0x4000 is 2^62.)

 I do need to learn at least some C, I know.  So far I have found a
 knoledge of Python and some Perl to be more useful. I'm assuming the
 "KR" to which you refer is an introductory C text?

Quoted from http://www.tuxedo.org/~esr/jargon/html/entry/Kamp;R.html

   KR [Kernighan and Ritchie] n.
   
   Brian Kernighan and Dennis Ritchie's book "The C Programming
   Language", esp. the classic and influential first edition
   (Prentice-Hall 1978; ISBN 0-13-110163-3). Syn. White Book, Old
   Testament. See also New Testament.
   
You probably want ``New Testament'' instead, actually, since it
covers ANSI C:

   New Testament n.
   
   [C programmers] The second edition of KR's "The C Programming
   Language" (Prentice-Hall, 1988; ISBN 0-13-110362-8), describing ANSI
   Standard C. See KR; this version is also called `KR2'.
   
Hope it helps,
---Chris K.
-- 
 Chris, the Young One |_ but what's a dropped message between friends? 
  Auckland, New Zealand |_ this is UDP, not TCP after all ;) ---John H. 
http://cloud9.hedgee.com/ |_ Robinson, IV