3 time2posix, posix2time \- convert seconds since the Epoch
6 .B #include <sys/types.h>
9 .B time_t time2posix(t)
12 .B time_t posix2time(t)
20 legislates that a time_t value of
21 536457599 shall correspond to "Wed Dec 31 23:59:59 UTC 1986."
22 This effectively implies that POSIX time_t's cannot include leap
25 that the system time must be adjusted as each leap occurs.
27 If the time package is configured with leap-second support
30 no such adjustment is needed and
31 time_t 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 time_t is intended
39 opaque\(emtime_t values should only be obtained-from and
40 passed-to functions such as
47 POSIX gives an arithmetic
48 expression for directly computing a time_t value from a given date/time,
49 and the same relationship is assumed by some
52 Any programs creating/dissecting time_t's
53 using such a relationship will typically not handle intervals
54 over leap seconds correctly.
60 functions are provided to address this time_t mismatch by converting
61 between local time_t values and their POSIX equivalents.
62 This is done by accounting for the number of time-base changes that
63 would have taken place on a POSIX system as leap seconds were inserted
65 These converted values can then be used in lieu of correcting the older
67 or when communicating with POSIX-compliant systems.
73 corresponds to a single POSIX time_t.
76 for a positive leap second hit the result is not unique,
77 and for a negative leap second hit the corresponding
78 POSIX time_t doesn't exist so an adjacent value is returned.
79 Both of these are good indicators of the inferiority of the
82 The following table summarizes the relationship between a time
83 T and it's conversion to,
85 the POSIX representation over the leap second inserted at the end of June,
88 .ta \w'93/06/30 'u +\w'23:59:59 'u +\w'A+0 'u +\w'X=time2posix(T) 'u
89 DATE TIME T X=time2posix(T) posix2time(X)
90 93/06/30 23:59:59 A+0 B+0 A+0
91 93/06/30 23:59:60 A+1 B+1 A+1 or A+2
92 93/07/01 00:00:00 A+2 B+1 A+1 or A+2
93 93/07/01 00:00:01 A+3 B+2 A+3
95 A leap second deletion would look like...
97 DATE TIME T X=time2posix(T) posix2time(X)
98 ??/06/30 23:59:58 A+0 B+0 A+0
99 ??/07/01 00:00:00 A+1 B+2 A+1
100 ??/07/01 00:00:01 A+2 B+3 A+2
103 [Note: posix2time(B+1) => A+0 or A+1]
106 If leap-second support is not enabled,
108 POSIX time_t's are equivalent,
113 degenerate to the identity function.
119 .\" @(#)time2posix.3 7.8
120 .\" This file is in the public domain, so clarified as of
121 .\" 1996-06-05 by Arthur David Olson.