1Time::TAI64(3) User Contributed Perl Documentation Time::TAI64(3)
2
3
4
6 Time::TAI64 - Perl extension for converting TAI64 strings into standard
7 unix timestamps.
8
10 Generate TAI64 timestamps
11
12 use Time::TAI64 qw/tai64n/;
13 use Time::HiRes qw/time/;
14
15 $now = time; # High precision
16 printf "%s\n", unixtai64n($now);
17
18 Print out human readable logs
19
20 use Time::TAI64 qw/:tai64n/;
21
22 open FILE, "/var/log/multilog/stats";
23 while(my $line = <FILE>) {
24 my($tai,$log) = split(' ',$line,2);
25 printf "%s %s",tai64nlocal($tai),$log;
26 }
27 close FILE;
28
30 This is a package provides routines to convert TAI64 strings, like
31 timestamps produced by multilog, into values that can be processed by
32 other perl functions to display the timestamp in human-readable form
33 and/or use in mathematical computations.
34
36 In order to use any of these functions, they must be properly imported
37 by using any of the following tags to use related functions:
38
39 :tai
40 Generic Functions
41
42 tai2unix ( $tai_string )
43 This method converts a tai64, tai64n, or tai64na string into a unix
44 timestamp. If successfull, this function returns an integer value
45 containing the number of seconds since Jan 1, 1970 as would perl's
46 "time" function. If an error occurs, the function returns a 0.
47
48 tai2strftime ( $tai64_string, $format_string )
49 This method converts the tai64, tai64n, or tai64na string given as
50 its first parameter and, returns a formatted string of the
51 converted timestamp as formatted by its second parameter using
52 strftime conventions.
53
54 If this second parameter is ommited, it defaults to "%a %b %d
55 %H:%M:%S %Y" which should print the timestamp as: Mon Nov 1
56 12:00:00 2004
57
58 :tai64
59 TAI64 Functions as well as Generic Functions
60
61 tai64unix ( $tai64_string )
62 This method converts the tai64 string given as its only parameter
63 and if successfull, returns a value for timestamp that is
64 compatible with the value returned from "time".
65
66 unixtai64 ( timestamp )
67 This method converts a unix timestamp into a TAI64 string.
68
69 :ta64n
70 TAI64N Functions as well as Generic Functions
71
72 tai64nunix ( $tai64n_string )
73 This method converts the tai64n string given as its only parameter
74 and if successfull, returns a value for timestamp that is
75 compatible with the value returned from "Time::HiRes::time".
76
77 unixtai64n ( timestamp )
78 unixtai64n ( seconds , nanoseconds )
79 This methods returns a tai64n string using the parameters supplied
80 by the user making the following assumptions:
81
82 · If seconds and nanoseconds are given, these values are used
83 to compute the tai64n string. If nanoseconds evaluates to
84 more than 1 second, the value of both seconds and nanoseconds
85 are reevaluated. Both seconds and nanoseconds are assumed to
86 be integers, any fractional part is truncated.
87
88 · If timestamp is an integer, nanoseconds is assumed to be 0.
89
90 · If timestamp is a "real" number, the integer part is used for
91 the seconds and the fractional part is converted to
92 nanoseconds.
93
94 tai64nlocal ( $tai64n_string )
95 This utility returns a string representing the tai64n timestamp
96 converted to local time in ISO format: YYYY-MM-DD
97 HH:MM:SS.SSSSSSSSS.
98
99 The reason to include this funtion is to provide compatibility with
100 the command-line version included in daemontools.
101
102 :tai64na
103 TAI64NA Functions as well as Generic Functions
104
105 tai64naunix ( $tai64na_string )
106 This method converts the tai64na string given as its only parameter
107 and if successfull, returns a value for timestamp that is
108 compatible with the value returned from "Time::HiRes::time".
109
110 unixtai64na ( timestamp )
111 unixtai64na ( seconds , nanoseconds , attoseconds )
112 This method returns a tai64na string unsing the parameters supplied
113 by the user making the following assumptions:
114
115 · If seconds, nanoseconds and attoseconds are given, these
116 values are used to compute the tai64na string. If either
117 nanoseconds evaluates to more than 1 second, or attoseconds
118 evaluates to more than 1 nanosecond, then seconds,
119 nanoseconds, and attoseconds are reevaluated. These values
120 are assumed to be integers, any fractional part is truncated.
121
122 · If timestamp is an integer, both nanoseconds and attoseconds
123 are assumed to be 0.
124
125 · If timestamp is a "real" number, the integer part is used for
126 the seconds and the fractional part is converted to
127 nanoseconds amd attoseconds.
128
130 http://pobox.com/~djb/libtai/tai64.html
131
132 http://cr.yp.to/daemontools.html
133
135 Jorge Valdes, <jorge@joval.info>
136
138 This module was started by AMS, but would not have been completed if
139 Iain Truskett hadn't taken over. After his death, Jorge Valdes assumed
140 ownership and rewrote it in Perl.
141
143 Copyright (C) 2004-2006 by Jorge Valdes
144
145 This library is free software; you can redistribute it and/or modify it
146 under the same terms as Perl itself, either Perl version 5.8.3 or, at
147 your option, any later version of Perl 5 you may have available.
148
150 The lastest version of this library is likely to be available from
151 CPAN.
152
154 Hey! The above document had some coding errors, which are explained
155 below:
156
157 Around line 439:
158 You forgot a '=back' before '=head1'
159
160
161
162perl v5.30.0 2019-07-26 Time::TAI64(3)