rename svn revision variable to one with underscore, to not pollute
[minix3.git] / commands / zoneinfo / time2posix.3.txt
blobb61e4c765a69460cfff586117eceaeb1ba55ae41
1 NAME
3      time2posix, posix2time - convert seconds since the Epoch
5 SYNOPSIS
6      #include <sys/types.h>
7      #include <time.h>
9      time_t time2posix(t)
10      time_t t
12      time_t posix2time(t)
13      time_t t
15      cc ... -ltz
17 DESCRIPTION
18      IEEE Standard 1003.1 (POSIX) legislates that a time_t value
19      of 536457599 shall correspond to "Wed Dec 31 23:59:59 UTC
20      1986."  This effectively implies that POSIX time_t's cannot
21      include leap seconds and, therefore, that the system time
22      must be adjusted as each leap occurs.
24      If the time package is configured with leap-second support
25      enabled, however, no such adjustment is needed and time_t
26      values continue to increase over leap events (as a true
27      `seconds since...' value).  This means that these values
28      will differ from those required by POSIX by the net number
29      of leap seconds inserted since the Epoch.
31      Typically this is not a problem as the type time_t is
32      intended to be (mostly) opaque-time_t values should only be
33      obtained-from and passed-to functions such as time(2),
34      localtime(3), mktime(3), and difftime(3).  However, POSIX
35      gives an arithmetic expression for directly computing a
36      time_t value from a given date/time, and the same
37      relationship is assumed by some (usually older)
38      applications.  Any programs creating/dissecting time_t's
39      using such a relationship will typically not handle
40      intervals over leap seconds correctly.
42      The time2posix and posix2time functions are provided to
43      address this time_t mismatch by converting between local
44      time_t values and their POSIX equivalents.  This is done by
45      accounting for the number of time-base changes that would
46      have taken place on a POSIX system as leap seconds were
47      inserted or deleted.  These converted values can then be
48      used in lieu of correcting the older applications, or when
49      communicating with POSIX-compliant systems.
51      Time2posix is single-valued.  That is, every local time_t
52      corresponds to a single POSIX time_t.  Posix2time is less
53      well-behaved:  for a positive leap second hit the result is
54      not unique, and for a negative leap second hit the
55      corresponding POSIX time_t doesn't exist so an adjacent
56      value is returned.  Both of these are good indicators of the
57      inferiority of the POSIX representation.
59      The following table summarizes the relationship between a
60      time T and it's conversion to, and back from, the POSIX
61      representation over the leap second inserted at the end of
62      June, 1993.
63      DATE     TIME     T   X=time2posix(T) posix2time(X)
64      93/06/30 23:59:59 A+0 B+0             A+0
65      93/06/30 23:59:60 A+1 B+1             A+1 or A+2
66      93/07/01 00:00:00 A+2 B+1             A+1 or A+2
67      93/07/01 00:00:01 A+3 B+2             A+3
69      A leap second deletion would look like...
71      DATE     TIME     T   X=time2posix(T) posix2time(X)
72      ??/06/30 23:59:58 A+0 B+0             A+0
73      ??/07/01 00:00:00 A+1 B+2             A+1
74      ??/07/01 00:00:01 A+2 B+3             A+2
76                      [Note: posix2time(B+1) => A+0 or A+1]
78      If leap-second support is not enabled, local time_t's and
79      POSIX time_t's are equivalent, and both time2posix and
80      posix2time degenerate to the identity function.
82 SEE ALSO
83      difftime(3), localtime(3), mktime(3), time(2)