3 time2posix, posix2time \- convert seconds since the Epoch
6 .ie \n(.g .ds - \f(CW-\fP
10 .B time_t time2posix(time_t t);
12 .B time_t posix2time(time_t t);
19 .ie '\(lq'' .ds lq \&"\"
21 .ie '\(rq'' .ds rq \&"\"
24 \\$3\*(lq\\$1\*(rq\\$2
28 requires the time_t value 536457599 to stand for 1986-12-31 23:59:59 UTC.
29 This effectively implies that POSIX time_t values cannot include leap
32 that the system time must be adjusted as each leap occurs.
34 If the time package is configured with leap-second support
37 no such adjustment is needed and
38 time_t values continue to increase over leap events
42 This means that these values will differ from those required by POSIX
43 by the net number of leap seconds inserted since the Epoch.
45 Typically this is not a problem as the type time_t is intended
48 opaque \*(en time_t values should only be obtained-from and
49 passed-to functions such as
56 POSIX gives an arithmetic
57 expression for directly computing a time_t value from a given date/time,
58 and the same relationship is assumed by some
61 Any programs creating/dissecting time_t's
62 using such a relationship will typically not handle intervals
63 over leap seconds correctly.
69 functions are provided to address this time_t mismatch by converting
70 between local time_t values and their POSIX equivalents.
71 This is done by accounting for the number of time-base changes that
72 would have taken place on a POSIX system as leap seconds were inserted
74 These converted values can then be used in lieu of correcting the older
76 or when communicating with POSIX-compliant systems.
82 corresponds to a single POSIX time_t.
85 for a positive leap second hit the result is not unique,
86 and for a negative leap second hit the corresponding
87 POSIX time_t doesn't exist so an adjacent value is returned.
88 Both of these are good indicators of the inferiority of the
91 The following table summarizes the relationship between a time
92 T and it's conversion to,
94 the POSIX representation over the leap second inserted at the end of June,
97 .ta \w'93/06/30 'u +\w'23:59:59 'u +\w'A+0 'u +\w'X=time2posix(T) 'u
98 DATE TIME T X=time2posix(T) posix2time(X)
99 93/06/30 23:59:59 A+0 B+0 A+0
100 93/06/30 23:59:60 A+1 B+1 A+1 or A+2
101 93/07/01 00:00:00 A+2 B+1 A+1 or A+2
102 93/07/01 00:00:01 A+3 B+2 A+3
104 A leap second deletion would look like...
106 DATE TIME T X=time2posix(T) posix2time(X)
107 ??/06/30 23:59:58 A+0 B+0 A+0
108 ??/07/01 00:00:00 A+1 B+2 A+1
109 ??/07/01 00:00:01 A+2 B+3 A+2
112 [Note: posix2time(B+1) => A+0 or A+1]
115 If leap-second support is not enabled,
117 POSIX time_t's are equivalent,
122 degenerate to the identity function.
128 .\" This file is in the public domain, so clarified as of
129 .\" 1996-06-05 by Arthur David Olson.