1 .\" This file is in the public domain, so clarified as of
2 .\" 2009-05-17 by Arthur David Olson.
3 .TH newctime 3 "" "Time Zone Database"
5 asctime, ctime, difftime, gmtime, localtime, mktime \- convert date and time
8 .ie \n(.g .ds - \f(CR-\fP
12 .BR "extern char *tzname[];" " /\(** (optional) \(**/"
14 .B [[deprecated]] char *ctime(time_t const *clock);
16 .B char *ctime_r(time_t const *clock, char *buf);
18 .B double difftime(time_t time1, time_t time0);
20 .B [[deprecated]] char *asctime(struct tm const *tm);
22 .B "char *asctime_r(struct tm const *restrict tm,"
23 .B " char *restrict result);"
25 .B struct tm *localtime(time_t const *clock);
27 .B "struct tm *localtime_r(time_t const *restrict clock,"
28 .B " struct tm *restrict result);"
30 .B "struct tm *localtime_rz(timezone_t restrict zone,"
31 .B " time_t const *restrict clock,"
32 .B " struct tm *restrict result);"
34 .B struct tm *gmtime(time_t const *clock);
36 .B "struct tm *gmtime_r(time_t const *restrict clock,"
37 .B " struct tm *restrict result);"
39 .B time_t mktime(struct tm *tm);
41 .B "time_t mktime_z(timezone_t restrict zone,"
42 .B " struct tm *restrict tm);"
49 .ie '\(lq'' .ds lq \&"\"
51 .ie '\(rq'' .ds rq \&"\"
54 \\$3\*(lq\\$1\*(rq\\$2
59 converts a long integer, pointed to by
61 and returns a pointer to a
66 Thu Nov 24 18:22:48 1986\n\0
69 Years requiring fewer than four characters are padded with leading zeroes.
70 For years longer than four characters, the string is of the form
74 Thu Nov 24 18:22:48 81986\n\0
77 with five spaces before the year.
78 These unusual formats are designed to make it less likely that older
79 software that expects exactly 26 bytes of output will mistakenly output
80 misleading values for out-of-range years.
84 timestamp represents the time in seconds since 1970-01-01 00:00:00
85 Coordinated Universal Time (UTC).
86 The POSIX standard says that timestamps must be nonnegative
87 and must ignore leap seconds.
88 Many implementations extend POSIX by allowing negative timestamps,
89 and can therefore represent timestamps that predate the
90 introduction of UTC and are some other flavor of Universal Time (UT).
91 Some implementations support leap seconds, in contradiction to POSIX.
95 function is deprecated starting in C23.
109 structures, described below.
113 corrects for the time zone and any time zone adjustments
114 (such as Daylight Saving Time in the United States).
123 to a pointer to a string that's the time zone abbreviation to be used with
130 converts to Coordinated Universal Time.
135 converts a time value contained in a
137 structure to a string,
138 as shown in the above example,
139 and returns a pointer to the string.
140 This function is deprecated starting in C23.
148 converts the broken-down time,
149 expressed as local time,
150 in the structure pointed to by
152 into a calendar time value with the same encoding as that of the values
156 The original values of the
160 components of the structure are ignored,
161 and the original values of the other components are not restricted
162 to their normal ranges.
163 (A positive or zero value for
167 to presume initially that daylight saving time
169 is or is not in effect for the specified time.
174 function to attempt to divine whether daylight saving time is in effect
175 for the specified time; in this case it does not use a consistent
176 rule and may give a different answer when later
177 presented with the same argument.)
178 On successful completion, the values of the
182 components of the structure are set appropriately,
183 and the other components are set to represent the specified calendar time,
184 but with their values forced to their normal ranges; the final value of
194 returns the specified calendar time;
195 If the calendar time cannot be represented,
201 returns the difference between two calendar times,
205 expressed in seconds.
214 are like their unsuffixed counterparts, except that they accept an
215 additional argument specifying where to store the result if successful.
222 are like their unsuffixed counterparts, except that they accept an
225 argument specifying the timezone to be used for conversion.
228 is null, UT is used; otherwise,
230 should be have been allocated by
232 and should not be freed until after all uses (e.g., by calls to
238 Declarations of all the functions and externals, and the
244 The structure (of type)
246 includes the following fields:
250 .ta 2n +\w'long tm_gmtoff;nn'u
251 int tm_sec; /\(** seconds (0\*(en60) \(**/
252 int tm_min; /\(** minutes (0\*(en59) \(**/
253 int tm_hour; /\(** hours (0\*(en23) \(**/
254 int tm_mday; /\(** day of month (1\*(en31) \(**/
255 int tm_mon; /\(** month of year (0\*(en11) \(**/
256 int tm_year; /\(** year \- 1900 \(**/
257 int tm_wday; /\(** day of week (Sunday = 0) \(**/
258 int tm_yday; /\(** day of year (0\*(en365) \(**/
259 int tm_isdst; /\(** is daylight saving time in effect? \(**/
260 char \(**tm_zone; /\(** time zone abbreviation (optional) \(**/
261 long tm_gmtoff; /\(** offset from UT in seconds (optional) \(**/
268 is non-zero if daylight saving time is in effect.
273 is the offset (in seconds) of the time represented
274 from UT, with positive values indicating east
275 of the Prime Meridian.
276 The field's name is derived from Greenwich Mean Time, a precursor of UT.
284 fields exist, and are filled in, only if arrangements to do
285 so were made when the library containing these functions was
289 variable is optional; also, there is no guarantee that
292 continue to exist in this form in future releases of this code.
294 .ta \w'/usr/share/zoneinfo/posixrules\0\0'u
295 /usr/share/zoneinfo timezone information directory
297 /usr/share/zoneinfo/localtime local timezone file
299 /usr/share/zoneinfo/posixrules default DST rules (obsolete,
300 and can cause bugs if present)
302 /usr/share/zoneinfo/GMT for UTC leap seconds
305 .B /usr/share/zoneinfo/GMT
307 UTC leap seconds are loaded from
308 .BR /usr/share/zoneinfo/posixrules .
323 overwritten by each call.
326 variable (once set) and the
330 both point to an array of characters that
331 can be freed or overwritten by later calls to the functions
336 if these functions affect the timezone information that specifies the
337 abbreviation in question.
338 The remaining functions and data are thread-safe.
347 behave strangely for years before 1000 or after 9999.
348 The 1989 and 1999 editions of the C Standard say
349 that years from \-99 through 999 are converted without
350 extra spaces, but this conflicts with longstanding
351 tradition and with this implementation.
352 The 2011 edition says that the behavior
353 is undefined if the year is before 1000 or after 9999.
354 Traditional implementations of these two functions are
355 restricted to years in the range 1900 through 2099.
356 To avoid this portability mess, new programs should use