1 .\" $NetBSD: time2posix.3,v 1.17 2010/12/17 01:30:14 wiz Exp $
10 .Nd convert seconds since the Epoch
16 .Fn time2posix "time_t t"
18 .Fn time2posix_z "const timezone_t tz" "time_t t"
20 .Fn posix2time "time_t t"
22 .Fn posix2time_z "const timezone_t tz" "time_t t"
27 value of 536457599 shall correspond to
28 .Dl Wed Dec 31 23:59:59 UTC 1986 .
29 This effectively implies that POSIX
31 cannot include leap seconds and, therefore,
32 that the system time must be adjusted as each leap occurs.
34 If the time package is configured with leap-second support
35 enabled, however, no such adjustment is needed and
37 values continue to increase over leap events
38 (as a true `seconds since...' value).
39 This means that these values will differ from those required by POSIX
40 by the net number of leap seconds inserted since the Epoch.
42 Typically this is not a problem as the type
44 is intended to be (mostly)
47 values should only be obtained-from and
48 passed-to functions such as
57 However, POSIX gives an arithmetic expression for directly computing a
59 value from a given date/time, and the same relationship is assumed by
60 some (usually older) applications.
61 Any programs creating/dissecting
63 using such a relationship will typically not handle intervals over
64 leap seconds correctly.
72 functions are provided to address this
74 mismatch by converting between local
76 values and their POSIX equivalents.
77 This is done by accounting for the number of time-base changes that would
78 have taken place on a POSIX system as leap seconds were inserted or deleted.
79 These converted values can then be used in lieu of correcting the
80 older applications, or when communicating with POSIX-compliant systems.
88 corresponds to a single POSIX
93 are less well-behaved: for a positive leap second hit the result is not
94 unique, and for a negative leap second hit the corresponding POSIX
96 doesn't exist so an adjacent value is returned.
97 Both of these are good indicators of the inferiority of the POSIX
102 variants of the two functions behave exactly like their counterparts,
103 but they operate in the given
105 argument which was previously allocated using
109 The following table summarizes the relationship between a
111 and its conversion to, and back from, the POSIX representation over
112 the leap second inserted at the end of June, 1993.
113 .Bl -column "93/06/30" "23:59:59" "A+0" "X=time2posix(T)" "posix2time(X)" -offset indent
114 .It Sy DATE TIME T X=time2posix(T) posix2time(X)
115 .It 93/06/30 23:59:59 A+0 B+0 A+0
116 .It 93/06/30 23:59:60 A+1 B+1 A+1 or A+2
117 .It 93/07/01 00:00:00 A+2 B+1 A+1 or A+2
118 .It 93/07/01 00:00:01 A+3 B+2 A+3
121 A leap second deletion would look like...
122 .Bl -column "??/06/30" "23:59:58" "A+0" "X=time2posix(T)" "posix2time(X)" -offset indent
123 .It Sy DATE TIME T X=time2posix(T) posix2time(X)
124 .It ??/06/30 23:59:58 A+0 B+0 A+0
125 .It ??/07/01 00:00:00 A+1 B+2 A+1
126 .It ??/07/01 00:00:01 A+2 B+3 A+2
128 [Note: posix2time(B+1) =\*[Gt] A+0 or A+1]
130 If leap-second support is not enabled, local
134 are equivalent, and both
138 degenerate to the identity function.
148 .\" @(#)time2posix.3 7.7
149 .\" This file is in the public domain, so clarified as of
150 .\" 1996-06-05 by Arthur David Olson.