1 .\" $NetBSD: time2posix.3,v 1.19 2014/10/07 21:51:03 christos 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"
30 .Dl Wed Dec 31 23:59:59 UTC 1986 .
31 This effectively implies that POSIX
33 values cannot include leap seconds and, therefore,
34 that the system time must be adjusted as each leap occurs.
36 If the time package is configured with leap-second support
37 enabled, however, no such adjustment is needed and
39 values continue to increase over leap events
41 .Dq "seconds since..."
43 This means that these values will differ from those required by POSIX
44 by the net number of leap seconds inserted since the Epoch.
46 Typically this is not a problem as the type
48 is intended to be (mostly)
51 values should only be obtained-from and
52 passed-to functions such as
61 However, POSIX gives an arithmetic expression for directly computing a
63 value from a given date/time, and the same relationship is assumed by
64 some (usually older) applications.
65 Any programs creating/dissecting
67 using such a relationship will typically not handle intervals over
68 leap seconds correctly.
76 functions are provided to address this
78 mismatch by converting between local
80 values and their POSIX equivalents.
81 This is done by accounting for the number of time-base changes that would
82 have taken place on a POSIX system as leap seconds were inserted or deleted.
83 These converted values can then be used in lieu of correcting the
84 older applications, or when communicating with POSIX-compliant systems.
92 corresponds to a single POSIX
97 are less well-behaved: for a positive leap second hit the result is not
98 unique, and for a negative leap second hit the corresponding POSIX
100 doesn't exist so an adjacent value is returned.
101 Both of these are good indicators of the inferiority of the POSIX
106 variants of the two functions behave exactly like their counterparts,
107 but they operate in the given
109 argument which was previously allocated using
113 The following table summarizes the relationship between a
115 and its conversion to, and back from, the POSIX representation over
116 the leap second inserted at the end of June, 1993.
117 .Bl -column "93/06/30" "23:59:59" "A+0" "X=time2posix(T)" "posix2time(X)" -offset indent
118 .It Sy DATE TIME T X=time2posix(T) posix2time(X)
119 .It 93/06/30 23:59:59 A+0 B+0 A+0
120 .It 93/06/30 23:59:60 A+1 B+1 A+1 or A+2
121 .It 93/07/01 00:00:00 A+2 B+1 A+1 or A+2
122 .It 93/07/01 00:00:01 A+3 B+2 A+3
125 A leap second deletion would look like...
126 .Bl -column "??/06/30" "23:59:58" "A+0" "X=time2posix(T)" "posix2time(X)" -offset indent
127 .It Sy DATE TIME T X=time2posix(T) posix2time(X)
128 .It ??/06/30 23:59:58 A+0 B+0 A+0
129 .It ??/07/01 00:00:00 A+1 B+2 A+1
130 .It ??/07/01 00:00:01 A+2 B+3 A+2
132 [Note: posix2time(B+1) =\*[Gt] A+0 or A+1]
134 If leap-second support is not enabled, local
138 are equivalent, and both
142 degenerate to the identity function.
152 .\" @(#)time2posix.3 7.7
153 .\" This file is in the public domain, so clarified as of
154 .\" 1996-06-05 by Arthur David Olson.