1 .\" $FreeBSD: src/lib/libc/stdtime/time2posix.3,v 1.9.2.4 2001/12/14 18:33:59 ru Exp $
2 .\" $DragonFly: src/lib/libc/stdtime/time2posix.3,v 1.3 2008/10/19 20:15:58 swildner Exp $
10 .Nd convert seconds since the Epoch
16 .Fn time2posix "const time_t *t"
18 .Fn posix2time "const time_t *t"
21 legislates that a time_t value of
22 536457599 shall correspond to "Wed Dec 31 23:59:59 UTC 1986."
23 This effectively implies that POSIX time_t's cannot include leap
26 that the system time must be adjusted as each leap occurs.
28 If the time package is configured with leap-second support
31 no such adjustment is needed and
32 time_t values continue to increase over leap events
33 (as a true `seconds since...' value).
34 This means that these values will differ from those required by POSIX
35 by the net number of leap seconds inserted since the Epoch.
37 Typically this is not a problem as the type time_t is intended
40 opaque\(emtime_t values should only be obtained-from and
41 passed-to functions such as
50 expression for directly computing a time_t value from a given date/time,
51 and the same relationship is assumed by some
54 Any programs creating/dissecting time_t's
55 using such a relationship will typically not handle intervals
56 over leap seconds correctly.
62 functions are provided to address this time_t mismatch by converting
63 between local time_t values and their POSIX equivalents.
64 This is done by accounting for the number of time-base changes that
65 would have taken place on a POSIX system as leap seconds were inserted
67 These converted values can then be used in lieu of correcting the older
69 or when communicating with POSIX-compliant systems.
73 function is single-valued.
76 corresponds to a single POSIX time_t.
79 function is less well-behaved:
80 for a positive leap second hit the result is not unique,
81 and for a negative leap second hit the corresponding
82 POSIX time_t doesn't exist so an adjacent value is returned.
83 Both of these are good indicators of the inferiority of the
86 The following table summarizes the relationship between time_t
87 and its conversion to,
89 the POSIX representation over the leap second inserted at the end of June,
91 .Bl -column "93/06/30" "23:59:59" "A+0" "X=time2posix(T)"
92 .It Sy "DATE TIME T X=time2posix(T) posix2time(X)"
93 .It "93/06/30 23:59:59 A+0 B+0 A+0"
94 .It "93/06/30 23:59:60 A+1 B+1 A+1 or A+2"
95 .It "93/07/01 00:00:00 A+2 B+1 A+1 or A+2"
96 .It "93/07/01 00:00:01 A+3 B+2 A+3"
99 A leap second deletion would look like...
100 .Bl -column "??/06/30" "23:59:58" "A+0" "X=time2posix(T)"
101 .It Sy "DATE TIME T X=time2posix(T) posix2time(X)"
102 .It "??/06/30 23:59:58 A+0 B+0 A+0"
103 .It "??/07/01 00:00:00 A+1 B+2 A+1"
104 .It "??/07/01 00:00:01 A+2 B+3 A+2"
107 .D1 No "[Note: posix2time(B+1) => A+0 or A+1]"
109 If leap-second support is not enabled,
111 POSIX time_t's are equivalent,
116 degenerate to the identity function.
122 .\" @(#)time2posix.3 8.1
123 .\" This file is in the public domain, so clarified as of
124 .\" 1996-06-05 by Arthur David Olson.