NAME
TAI64 - Perl extension for converting TAI64 strings into standard unix timestamps.
SYNOPSIS
Generate TAI64 timestamps
use Time::TAI64;
use Time::HiRes qw(time);
$now = time; # High precision
printf "%s\n", unixtai64n($now);
Print out human readable logs
use Time::TAI64;
open FILE, "/var/log/multilog/stats";
while(my $line = <FILE>) {
my($tai,$log) = split ' ',$line,2;
printf "%s %s\n",tai64nlocal($tai),$log;
}
close FILE;
DESCRIPTION
This is a package provides routines to convert TAI64 strings, like timestamps produced by multilog, into values that can be processed by other perl functions to display the timestamp in human-readable form and/or use in mathematical computations.
EXPORTS
The following functions are available to the user:
- tai2unix ( $tai_string )
-
This method converts a tai64, tai64n, or tai64na string into a unix timestamp. If successfull, this function returns an integer value containing the number of seconds since Jan 1, 1970 as would perl's
time
function. If an error occurs, the function returns a 0. - tai64unix ( $tai64n_string )
-
This method converts the tai64 string given as its only parameter and if successfull, returns a value of timestamp that is compatible with the value returned from
time
. - tai64nunix ( $tai64n_string )
-
This method converts the tai64n string given as its only parameter and if successfull, returns a value of timestamp that is compatible with the value returned from
Time::HiRes::time
. - tai64naunix ( $tai64na_string )
-
This method converts the tai64na string given as its only parameter and if successfull, returns a value of timestamp that is compatible with the value returned from
Time::HiRes::time
. - tai64nlocal ( $tai64n_string )
-
This method converts the tai64n string given as its only parameter and if successfull, returns a formatted string of the converted timestamp as would the result of scalar(localtime(timestamp)). It returns an empty string if the conversion fails.
- unixtai64 ( timestamp )
-
This method converts a unix timestamp into a TAI64 string.
- unixtai64n ( timestamp )
- unixtai64n ( seconds , nanoseconds )
-
This methods returns a tai64n string using the parameters supplied by the user.
If seconds and nanoseconds are given, these values are used to compute the tai64n string. If nanoseconds evaluates to more than 1 second, the value of both seconds and nanoseconds are reevaluated. Both seconds and nanoseconds are assumed to be integers, any factional part is truncated.
If timestamp is an integer, nanoseconds is assumed to be 0.
If timestamp is a
real
number, the integer part is used for the seconds and the fractional part is converted to nanoseconds. - unixtai64na ( timestamp )
- unixtai64na ( seconds , nanoseconds , attoseconds )
-
This method returns a tai64na string unsing the parameters supplied by the user.
If seconds and nanoseconds and attoseconds are given, these values are used to compute the tai64na string. If either nanoseconds evaluates to more than 1 second, or attoseconds evaluates to more than 1 nanosecond, then seconds, nanoseconds, and attoseconds are reevaluated. These values are assumed to be integers, any fractional part is truncated.
SEE ALSO
http://pobox.com/~djb/libtai/tai64.html
AUTHOR
Jorge Valdes, <jvaldes@intercom.com.sv>
COPYRIGHT AND LICENSE
Copyright (C) 2004 by Jorge Valdes
This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself, either Perl version 5.8.3 or, at your option, any later version of Perl 5 you may have available.
AVAILABILITY
The lastest version of this library is likely to be available from CPAN.
1 POD Error
The following errors were encountered while parsing the POD:
- Around line 398:
You forgot a '=back' before '=head1'