1 .\" $NetBSD: time2posix.3,v 1.14 2009/04/11 16:29:09 joerg Exp $
8 .Nd convert seconds since the Epoch
14 .Fn time2posix "time_t t"
16 .Fn posix2time "time_t t"
21 value of 536457599 shall correspond to
22 .Dl Wed Dec 31 23:59:59 UTC 1986 .
23 This effectively implies that POSIX
25 cannot include leap seconds and, therefore,
26 that the system time must be adjusted as each leap occurs.
28 If the time package is configured with leap-second support
29 enabled, however, no such adjustment is needed and
31 values continue to increase over leap events
32 (as a true `seconds since...' value).
33 This means that these values will differ from those required by POSIX
34 by the net number of leap seconds inserted since the Epoch.
36 Typically this is not a problem as the type
38 is intended to be (mostly)
41 values should only be obtained-from and
42 passed-to functions such as
48 However, POSIX gives an arithmetic expression for directly computing a
50 value from a given date/time, and the same relationship is assumed by
51 some (usually older) applications.
52 Any programs creating/dissecting
54 using such a relationship will typically not handle intervals over
55 leap seconds correctly.
61 functions are provided to address this
63 mismatch by converting between local
65 values and their POSIX equivalents.
66 This is done by accounting for the number of time-base changes that would
67 have taken place on a POSIX system as leap seconds were inserted or deleted.
68 These converted values can then be used in lieu of correcting the
69 older applications, or when communicating with POSIX-compliant systems.
75 corresponds to a single POSIX
78 is less well-behaved: for a positive leap second hit the result is not
79 unique, and for a negative leap second hit the corresponding POSIX
81 doesn't exist so an adjacent value is returned.
82 Both of these are good indicators of the inferiority of the POSIX
85 The following table summarizes the relationship between a
87 and its conversion to, and back from, the POSIX representation over
88 the leap second inserted at the end of June, 1993.
89 .Bl -column "93/06/30" "23:59:59" "A+0" "X=time2posix(T)" "posix2time(X)" -offset indent
90 .It Sy DATE TIME T X=time2posix(T) posix2time(X)
91 .It 93/06/30 23:59:59 A+0 B+0 A+0
92 .It 93/06/30 23:59:60 A+1 B+1 A+1 or A+2
93 .It 93/07/01 00:00:00 A+2 B+1 A+1 or A+2
94 .It 93/07/01 00:00:01 A+3 B+2 A+3
97 A leap second deletion would look like...
98 .Bl -column "??/06/30" "23:59:58" "A+0" "X=time2posix(T)" "posix2time(X)" -offset indent
99 .It Sy DATE TIME T X=time2posix(T) posix2time(X)
100 .It ??/06/30 23:59:58 A+0 B+0 A+0
101 .It ??/07/01 00:00:00 A+1 B+2 A+1
102 .It ??/07/01 00:00:01 A+2 B+3 A+2
104 [Note: posix2time(B+1) =\*[Gt] A+0 or A+1]
106 If leap-second support is not enabled, local
110 are equivalent, and both
114 degenerate to the identity function.
120 .\" @(#)time2posix.3 7.7
121 .\" This file is in the public domain, so clarified as of
122 .\" 1996-06-05 by Arthur David Olson.