Suppose you'd like to make note of the time of some event that takes place in your program. The tai-now function uses Common Lisp get-universal-time and returns an object referred to as tai64 internal format. It essentially returns a large integer in the range of 0 to 2^64.

CL-LIBTAI> (tai-now)
((X . 4611686019563208944))
To convert this to tai64 external format, run it through tai-pack. The result of this function is a 16byte hexadecimal string, particularly suited for reading or writing to standard input or output. The contents of either of these are generally suitable for writing to disk, or sending to/from the network perhaps in the form of a netstring.
CL-LIBTAI> (tai-pack (tai-now))
On the receiving end, you can run tai-unpack to get back to the internal tai64 object, and pass it to caltime-utc to create a caltime object. caltime-utc takes the tai64 object in internal form and breaks it down into year, month day, and hour, minute second components. As you can see from this example tai-unpack takes the tai64 external format which is always in the form of a hexadecimal string.
CL-LIBTAI> (caltime-utc (tai-unpack "4000000043B34295"))
((OFFSET . 0) (SECOND . 9) (MINUTE . 57) (HOUR . 1)
 (DATE :YEAR 2005 :MONTH 12 :DAY 29))
You can also populate a caltime object and then get it converted to tai64 internal form. Thats done with the caltime-tai function, as follows:
CL-LIBTAI> (caltime-tai (make-caltime (make-caldate 2005 12 29) 1 57 9 0))
((X . 4611686019563209365))
You can see that it returns a large number again, in the range of 0 to 2^64, which is the tai64 internal format. You can pack that up as external form by passing the result to tai-pack.

Back to project cl-libtai.

Valid XHTML 1.0 Strict