3 asctime, ctime, difftime, gmtime, localtime, mktime \- convert date and time
6 .ie \n(.g .ds - \f(CW-\fP
10 .B extern char *tzname[2];
12 .B char *ctime(time_t const *clock);
14 .B char *ctime_r(time_t const *clock, char *buf);
16 .B double difftime(time_t time1, time_t time0);
18 .B char *asctime(struct tm const *tm);
20 .B "char *asctime_r(struct tm const *restrict tm,"
21 .B " char *restrict result);"
23 .B struct tm *localtime(time_t const *clock);
25 .B "struct tm *localtime_r(time_t const *restrict clock,"
26 .B " struct tm *restrict result);"
28 .B "struct tm *localtime_rz(timezone_t restrict zone,"
29 .B " time_t const *restrict clock,"
30 .B " struct tm *restrict result);"
32 .B struct tm *gmtime(time_t const *clock);
34 .B "struct tm *gmtime_r(time_t const *restrict clock,"
35 .B " struct tm *restrict result);"
37 .B time_t mktime(struct tm *tm);
39 .B "time_t mktime_z(timezone_t restrict zone,"
40 .B " struct tm *restrict tm);"
47 .ie '\(lq'' .ds lq \&"\"
49 .ie '\(rq'' .ds rq \&"\"
52 \\$3\*(lq\\$1\*(rq\\$2
55 converts a long integer, pointed to by
57 and returns a pointer to a
62 Thu Nov 24 18:22:48 1986\n\0
65 Years requiring fewer than four characters are padded with leading zeroes.
66 For years longer than four characters, the string is of the form
70 Thu Nov 24 18:22:48 81986\n\0
73 with five spaces before the year.
74 These unusual formats are designed to make it less likely that older
75 software that expects exactly 26 bytes of output will mistakenly output
76 misleading values for out-of-range years.
80 timestamp represents the time in seconds since 1970-01-01 00:00:00
81 Coordinated Universal Time (UTC).
82 The POSIX standard says that timestamps must be nonnegative
83 and must ignore leap seconds.
84 Many implementations extend POSIX by allowing negative timestamps,
85 and can therefore represent timestamps that predate the
86 introduction of UTC and are some other flavor of Universal Time (UT).
87 Some implementations support leap seconds, in contradiction to POSIX.
94 structures, described below.
96 corrects for the time zone and any time zone adjustments
97 (such as Daylight Saving Time in the United States).
106 to a pointer to a string that's the time zone abbreviation to be used with
111 converts to Coordinated Universal Time.
114 converts a time value contained in a
116 structure to a string,
117 as shown in the above example,
118 and returns a pointer to the string.
121 converts the broken-down time,
122 expressed as local time,
123 in the structure pointed to by
125 into a calendar time value with the same encoding as that of the values
129 The original values of the
133 components of the structure are ignored,
134 and the original values of the other components are not restricted
135 to their normal ranges.
136 (A positive or zero value for
140 to presume initially that summer time (for example, Daylight Saving Time
143 is or is not in effect for the specified time.
148 function to attempt to divine whether summer time is in effect
149 for the specified time; in this case it does not use a consistent
150 rule and may give a different answer when later
151 presented with the same argument.)
152 On successful completion, the values of the
156 components of the structure are set appropriately,
157 and the other components are set to represent the specified calendar time,
158 but with their values forced to their normal ranges; the final value of
166 returns the specified calendar time;
167 If the calendar time cannot be represented,
171 returns the difference between two calendar times,
175 expressed in seconds.
182 are like their unsuffixed counterparts, except that they accept an
183 additional argument specifying where to store the result if successful.
188 are like their unsuffixed counterparts, except that they accept an
191 argument specifying the time zone to be used for conversion.
194 is null, UTC is used; otherwise,
196 should be have been allocated by
198 and should not be freed until after all uses (e.g., by calls to
204 Declarations of all the functions and externals, and the
210 The structure (of type)
212 includes the following fields:
216 .ta .5i +\w'long tm_gmtoff;\0\0'u
217 int tm_sec; /\(** seconds (0\*(en60) \(**/
218 int tm_min; /\(** minutes (0\*(en59) \(**/
219 int tm_hour; /\(** hours (0\*(en23) \(**/
220 int tm_mday; /\(** day of month (1\*(en31) \(**/
221 int tm_mon; /\(** month of year (0\*(en11) \(**/
222 int tm_year; /\(** year \- 1900 \(**/
223 int tm_wday; /\(** day of week (Sunday = 0) \(**/
224 int tm_yday; /\(** day of year (0\*(en365) \(**/
225 int tm_isdst; /\(** is summer time in effect? \(**/
226 char \(**tm_zone; /\(** abbreviation of time zone name \(**/
227 long tm_gmtoff; /\(** offset from UT in seconds \(**/
235 fields exist, and are filled in, only if arrangements to do
236 so were made when the library containing these functions was
238 There is no guarantee that these fields will continue to exist
239 in this form in future releases of this code.
242 is non-zero if summer time is in effect.
245 is the offset (in seconds) of the time represented
246 from UT, with positive values indicating east
247 of the Prime Meridian.
248 The field's name is derived from Greenwich Mean Time, a precursor of UT.
250 .ta \w'/usr/local/etc/zoneinfo/posixrules\0\0'u
251 /usr/local/etc/zoneinfo time zone information directory
253 /usr/local/etc/zoneinfo/localtime local time zone file
255 /usr/local/etc/zoneinfo/posixrules used with POSIX-style TZ's
257 /usr/local/etc/zoneinfo/GMT for UTC leap seconds
260 .B /usr/local/etc/zoneinfo/GMT
262 UTC leap seconds are loaded from
263 .BR /usr/local/etc/zoneinfo/posixrules .
278 overwritten by each call.
283 points to a static array of characters, which
284 can be overwritten by later calls to
286 The remaining functions and data are thread-safe.
293 behave strangely for years before 1000 or after 9999.
294 The 1989 and 1999 editions of the C Standard say
295 that years from \-99 through 999 are converted without
296 extra spaces, but this conflicts with longstanding
297 tradition and with this implementation.
298 The 2011 edition says that the behavior
299 is undefined if the year is before 1000 or after 9999.
300 Traditional implementations of these two functions are
301 restricted to years in the range 1900 through 2099.
302 To avoid this portability mess, new programs should use
305 .\" This file is in the public domain, so clarified as of
306 .\" 2009-05-17 by Arthur David Olson.