faqts : Computers : Internet : Domain Names : djbdns

+ Search
Add Entry AlertManage Folder Edit Entry Add page to http://del.icio.us/
Did You Find This Entry Useful?

22 of 22 people (100%) answered Yes
Recently 10 of 10 people (100%) answered Yes

Entry

How do I calculate tai64 timestamps for my data file given human readable local time?

Oct 17th, 2003 06:13
Henry Gremming, Brian Coogan, Rob Mayoff,


Tai timestamps are used in the ending timestamps on tinydns data lines 
to specify the time at which a line should either come into effect or 
cease to be effective.  This allows you to automate cutover to a new IP 
address for a host simply.  Tinydns returns a steadily decreasing TTL 
of the number of seconds left until the cutover time, then presents the 
new IP address automatically after the cutover time.  This is all 
documented in the webpages.
(See http://cr.yp.to/djbdns/tinydns-data.html under "Data format")
There are several alternatives for producing these times -
Rob Mayoff has a web form that translates human-readable times (in
several formats) to TAI64 labels:
  http://dqd.com/~mayoff/tools/djbdns/make-tai.adp
A number of people came up with another solution involving GNU date:
  date +"16o2 62^%s+2 32^*p" | dc | tr A-Z a-z
A --date="string"  can be used to specify arbitrary dates.  
Another alternative uses bc:
  echo 40000000`(echo obase = 16; date +%s) | bc`00000000 | tail -1
The tail -1 is to discard readline's input echoing on some systems.
Even better: all you need is the libtai package from Prof. Bernstein
http://cr.yp.to/libtai.html
After compilation (no need to install anything) you get a small program,
 check, which is intended to carry out different tests. If you pipe a
date to check it will output the Tai timestamp we wanted:
echo "2003-10-18 12:00:00 +0000"|check
gives
400000003f912b60 290  Sat 2020-10-18 12:00:00 +0000