xref: /freebsd-src/lib/libc/stdtime/ctime.3 (revision 7534109d13a6cdb22e78d9d4c0a0cd5efd323c45)
1bc421551SDag-Erling Smørgrav.\" Copyright (c) 1989, 1991, 1993
2bc421551SDag-Erling Smørgrav.\"	The Regents of the University of California.  All rights reserved.
3bc421551SDag-Erling Smørgrav.\"
4bc421551SDag-Erling Smørgrav.\" This code is derived from software contributed to Berkeley by
5bc421551SDag-Erling Smørgrav.\" Arthur Olson.
6bc421551SDag-Erling Smørgrav.\" Redistribution and use in source and binary forms, with or without
7bc421551SDag-Erling Smørgrav.\" modification, are permitted provided that the following conditions
8bc421551SDag-Erling Smørgrav.\" are met:
9bc421551SDag-Erling Smørgrav.\" 1. Redistributions of source code must retain the above copyright
10bc421551SDag-Erling Smørgrav.\"    notice, this list of conditions and the following disclaimer.
11bc421551SDag-Erling Smørgrav.\" 2. Redistributions in binary form must reproduce the above copyright
12bc421551SDag-Erling Smørgrav.\"    notice, this list of conditions and the following disclaimer in the
13bc421551SDag-Erling Smørgrav.\"    documentation and/or other materials provided with the distribution.
14bc421551SDag-Erling Smørgrav.\" 3. Neither the name of the University nor the names of its contributors
15bc421551SDag-Erling Smørgrav.\"    may be used to endorse or promote products derived from this software
16bc421551SDag-Erling Smørgrav.\"    without specific prior written permission.
17bc421551SDag-Erling Smørgrav.\"
18bc421551SDag-Erling Smørgrav.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
19bc421551SDag-Erling Smørgrav.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
20bc421551SDag-Erling Smørgrav.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
21bc421551SDag-Erling Smørgrav.\" ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
22bc421551SDag-Erling Smørgrav.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
23bc421551SDag-Erling Smørgrav.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
24bc421551SDag-Erling Smørgrav.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
25bc421551SDag-Erling Smørgrav.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
26bc421551SDag-Erling Smørgrav.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
27bc421551SDag-Erling Smørgrav.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
28bc421551SDag-Erling Smørgrav.\" SUCH DAMAGE.
29bc421551SDag-Erling Smørgrav.\"
30*7534109dSDag-Erling Smørgrav.Dd March 26, 2024
31bc421551SDag-Erling Smørgrav.Dt CTIME 3
32bc421551SDag-Erling Smørgrav.Os
33bc421551SDag-Erling Smørgrav.Sh NAME
34bc421551SDag-Erling Smørgrav.Nm asctime ,
35bc421551SDag-Erling Smørgrav.Nm asctime_r ,
36bc421551SDag-Erling Smørgrav.Nm ctime ,
37bc421551SDag-Erling Smørgrav.Nm ctime_r ,
38bc421551SDag-Erling Smørgrav.Nm difftime ,
39bc421551SDag-Erling Smørgrav.Nm gmtime ,
40bc421551SDag-Erling Smørgrav.Nm gmtime_r ,
41bc421551SDag-Erling Smørgrav.Nm localtime ,
42bc421551SDag-Erling Smørgrav.Nm localtime_r ,
43bc421551SDag-Erling Smørgrav.Nm mktime ,
44bc421551SDag-Erling Smørgrav.Nm timegm
45bc421551SDag-Erling Smørgrav.Nd transform binary date and time values
46bc421551SDag-Erling Smørgrav.Sh LIBRARY
47bc421551SDag-Erling Smørgrav.Lb libc
48bc421551SDag-Erling Smørgrav.Sh SYNOPSIS
49bc421551SDag-Erling Smørgrav.In time.h
50bc421551SDag-Erling Smørgrav.Vt extern char *tzname[2] ;
51bc421551SDag-Erling Smørgrav.Ft char *
526f3c2f41SDag-Erling Smørgrav.Fn asctime "const struct tm *tm"
536f3c2f41SDag-Erling Smørgrav.Ft char *
546f3c2f41SDag-Erling Smørgrav.Fn asctime_r "const struct tm *tm" "char *buf"
556f3c2f41SDag-Erling Smørgrav.Ft char *
56bc421551SDag-Erling Smørgrav.Fn ctime "const time_t *clock"
576f3c2f41SDag-Erling Smørgrav.Ft char *
586f3c2f41SDag-Erling Smørgrav.Fn ctime_r "const time_t *clock" "char *buf"
59bc421551SDag-Erling Smørgrav.Ft double
60bc421551SDag-Erling Smørgrav.Fn difftime "time_t time1" "time_t time0"
616f3c2f41SDag-Erling Smørgrav.Ft struct tm *
626f3c2f41SDag-Erling Smørgrav.Fn gmtime "const time_t *clock"
636f3c2f41SDag-Erling Smørgrav.Ft struct tm *
646f3c2f41SDag-Erling Smørgrav.Fn gmtime_r "const time_t *clock" "struct tm *result"
65bc421551SDag-Erling Smørgrav.Ft struct tm *
66bc421551SDag-Erling Smørgrav.Fn localtime "const time_t *clock"
67bc421551SDag-Erling Smørgrav.Ft struct tm *
686f3c2f41SDag-Erling Smørgrav.Fn localtime_r "const time_t *clock" "struct tm *result"
69bc421551SDag-Erling Smørgrav.Ft time_t
70bc421551SDag-Erling Smørgrav.Fn mktime "struct tm *tm"
71bc421551SDag-Erling Smørgrav.Ft time_t
72bc421551SDag-Erling Smørgrav.Fn timegm "struct tm *tm"
73bc421551SDag-Erling Smørgrav.Sh DESCRIPTION
746f3c2f41SDag-Erling SmørgravThe
75bc421551SDag-Erling Smørgrav.Fn ctime ,
766f3c2f41SDag-Erling Smørgrav.Fn gmtime ,
77bc421551SDag-Erling Smørgravand
78bc421551SDag-Erling Smørgrav.Fn localtime
796f3c2f41SDag-Erling Smørgravfunctions all take as argument a pointer to a time value representing
806f3c2f41SDag-Erling Smørgravthe time in seconds since the Epoch (00:00:00 UTC on January 1, 1970;
816f3c2f41SDag-Erling Smørgravsee
82bc421551SDag-Erling Smørgrav.Xr time 3 ) .
83bc421551SDag-Erling Smørgrav.Pp
846f3c2f41SDag-Erling SmørgravThe
85bc421551SDag-Erling Smørgrav.Fn localtime
866f3c2f41SDag-Erling Smørgravfunction converts the time value pointed to by
87bc421551SDag-Erling Smørgrav.Fa clock ,
88bc421551SDag-Erling Smørgravand returns a pointer to a
896f3c2f41SDag-Erling Smørgrav.Vt struct tm
90bc421551SDag-Erling Smørgrav(described below) which contains
91bc421551SDag-Erling Smørgravthe broken-out time information for the value after adjusting for the current
926f3c2f41SDag-Erling Smørgravtime zone (see
93bc421551SDag-Erling Smørgrav.Xr tzset 3 ) .
946f3c2f41SDag-Erling SmørgravWhen the specified time translates to a year that will not fit in an
956f3c2f41SDag-Erling Smørgrav.Vt int ,
96bc421551SDag-Erling Smørgrav.Fn localtime
976f3c2f41SDag-Erling Smørgravreturns
986f3c2f41SDag-Erling Smørgrav.Dv NULL .
996f3c2f41SDag-Erling SmørgravThe
1006f3c2f41SDag-Erling Smørgrav.Fn localtime
1016f3c2f41SDag-Erling Smørgravfunction uses
102bc421551SDag-Erling Smørgrav.Xr tzset 3
103bc421551SDag-Erling Smørgravto initialize time conversion information if
104bc421551SDag-Erling Smørgrav.Xr tzset 3
105bc421551SDag-Erling Smørgravhas not already been called by the process.
106bc421551SDag-Erling Smørgrav.Pp
1076f3c2f41SDag-Erling SmørgravAfter filling in the
1086f3c2f41SDag-Erling Smørgrav.Vt struct tm ,
109bc421551SDag-Erling Smørgrav.Fn localtime
110bc421551SDag-Erling Smørgravsets the
1116f3c2f41SDag-Erling Smørgrav.Va tm_isdst Ns 'th
112bc421551SDag-Erling Smørgravelement of
1136f3c2f41SDag-Erling Smørgrav.Va tzname
1146f3c2f41SDag-Erling Smørgravto a pointer to an ASCII string that is the time zone abbreviation to be
115bc421551SDag-Erling Smørgravused with
116bc421551SDag-Erling Smørgrav.Fn localtime Ns 's
117bc421551SDag-Erling Smørgravreturn value.
118bc421551SDag-Erling Smørgrav.Pp
1196f3c2f41SDag-Erling SmørgravThe
120bc421551SDag-Erling Smørgrav.Fn gmtime
1216f3c2f41SDag-Erling Smørgravfunction similarly converts the time value, but without any time zone
1226f3c2f41SDag-Erling Smørgravadjustment, and returns a pointer to a
1236f3c2f41SDag-Erling Smørgrav.Vt struct tm .
124bc421551SDag-Erling Smørgrav.Pp
125bc421551SDag-Erling SmørgravThe
126bc421551SDag-Erling Smørgrav.Fn ctime
127bc421551SDag-Erling Smørgravfunction
128bc421551SDag-Erling Smørgravadjusts the time value for the current time zone in the same manner as
129bc421551SDag-Erling Smørgrav.Fn localtime ,
130bc421551SDag-Erling Smørgravand returns a pointer to a 26-character string of the form:
131bc421551SDag-Erling Smørgrav.Bd -literal -offset indent
132bc421551SDag-Erling SmørgravThu Nov 24 18:22:48 1986\en\e0
133bc421551SDag-Erling Smørgrav.Ed
134bc421551SDag-Erling Smørgrav.Pp
135bc421551SDag-Erling SmørgravAll the fields have constant width.
136bc421551SDag-Erling Smørgrav.Pp
137bc421551SDag-Erling SmørgravThe
1386f3c2f41SDag-Erling Smørgrav.Fn asctime
1396f3c2f41SDag-Erling Smørgravfunction converts the broken down time in the
1406f3c2f41SDag-Erling Smørgrav.Vt struct tm
1416f3c2f41SDag-Erling Smørgravpointed to by
1426f3c2f41SDag-Erling Smørgrav.Fa tm
1436f3c2f41SDag-Erling Smørgravto the form shown in the example above.
1446f3c2f41SDag-Erling Smørgrav.Pp
1456f3c2f41SDag-Erling SmørgravThe
146bc421551SDag-Erling Smørgrav.Fn ctime_r
1476f3c2f41SDag-Erling Smørgravand
1486f3c2f41SDag-Erling Smørgrav.Fn asctime_r
1496f3c2f41SDag-Erling Smørgravfunctions
1506f3c2f41SDag-Erling Smørgravprovide the same functionality as
151bc421551SDag-Erling Smørgrav.Fn ctime
1526f3c2f41SDag-Erling Smørgravand
1536f3c2f41SDag-Erling Smørgrav.Fn asctime
154bc421551SDag-Erling Smørgravexcept the caller must provide the output buffer
1556f3c2f41SDag-Erling Smørgrav.Fa buf ,
1566f3c2f41SDag-Erling Smørgravwhich must be at least 26 characters long, to store the result in.
157bc421551SDag-Erling SmørgravThe
158bc421551SDag-Erling Smørgrav.Fn localtime_r
159bc421551SDag-Erling Smørgravand
160bc421551SDag-Erling Smørgrav.Fn gmtime_r
1616f3c2f41SDag-Erling Smørgravfunctions provide the same functionality as
162bc421551SDag-Erling Smørgrav.Fn localtime
163bc421551SDag-Erling Smørgravand
164bc421551SDag-Erling Smørgrav.Fn gmtime
165bc421551SDag-Erling Smørgravrespectively, except the caller must provide the output buffer
166bc421551SDag-Erling Smørgrav.Fa result .
167bc421551SDag-Erling Smørgrav.Pp
168bc421551SDag-Erling SmørgravThe functions
169bc421551SDag-Erling Smørgrav.Fn mktime
170bc421551SDag-Erling Smørgravand
171bc421551SDag-Erling Smørgrav.Fn timegm
1726f3c2f41SDag-Erling Smørgravconvert the broken-down time in the
1736f3c2f41SDag-Erling Smørgrav.Vt struct tm
1746f3c2f41SDag-Erling Smørgravpointed to by
1756f3c2f41SDag-Erling Smørgrav.Fa tm
1766f3c2f41SDag-Erling Smørgravinto a time value with the same encoding as that of the values
1776f3c2f41SDag-Erling Smørgravreturned by the
178bc421551SDag-Erling Smørgrav.Xr time 3
1796f3c2f41SDag-Erling Smørgravfunction (that is, seconds from the Epoch, UTC).
180bc421551SDag-Erling SmørgravThe
181bc421551SDag-Erling Smørgrav.Fn mktime
1826f3c2f41SDag-Erling Smørgravfunction interprets the input structure according to the current
1836f3c2f41SDag-Erling Smørgravtimezone setting (see
1846f3c2f41SDag-Erling Smørgrav.Xr tzset 3 )
1856f3c2f41SDag-Erling Smørgravwhile the
186bc421551SDag-Erling Smørgrav.Fn timegm
1876f3c2f41SDag-Erling Smørgravfunction interprets the input structure as representing Universal
1886f3c2f41SDag-Erling SmørgravCoordinated Time
1896f3c2f41SDag-Erling Smørgrav.Pq UTC .
190bc421551SDag-Erling Smørgrav.Pp
191bc421551SDag-Erling SmørgravThe original values of the
192bc421551SDag-Erling Smørgrav.Fa tm_wday
193bc421551SDag-Erling Smørgravand
194bc421551SDag-Erling Smørgrav.Fa tm_yday
195bc421551SDag-Erling Smørgravcomponents of the structure are ignored, and the original values of the
196bc421551SDag-Erling Smørgravother components are not restricted to their normal ranges, and will be
197bc421551SDag-Erling Smørgravnormalized if needed.
198bc421551SDag-Erling SmørgravFor example,
199bc421551SDag-Erling SmørgravOctober 40 is changed into November 9,
200bc421551SDag-Erling Smørgrava
201bc421551SDag-Erling Smørgrav.Fa tm_hour
202bc421551SDag-Erling Smørgravof \-1 means 1 hour before midnight,
203bc421551SDag-Erling Smørgrav.Fa tm_mday
204bc421551SDag-Erling Smørgravof 0 means the day preceding the current month, and
205bc421551SDag-Erling Smørgrav.Fa tm_mon
206bc421551SDag-Erling Smørgravof \-2 means 2 months before January of
207bc421551SDag-Erling Smørgrav.Fa tm_year .
208bc421551SDag-Erling Smørgrav(A positive or zero value for
209bc421551SDag-Erling Smørgrav.Fa tm_isdst
210bc421551SDag-Erling Smørgravcauses
211bc421551SDag-Erling Smørgrav.Fn mktime
212bc421551SDag-Erling Smørgravto presume initially that summer time (for example, Daylight Saving Time)
213bc421551SDag-Erling Smørgravis or is not in effect for the specified time, respectively.
214bc421551SDag-Erling SmørgravA negative value for
215bc421551SDag-Erling Smørgrav.Fa tm_isdst
216bc421551SDag-Erling Smørgravcauses the
217bc421551SDag-Erling Smørgrav.Fn mktime
2186f3c2f41SDag-Erling Smørgravfunction to attempt to guess whether summer time is in effect for the
219bc421551SDag-Erling Smørgravspecified time.
220bc421551SDag-Erling SmørgravThe
221bc421551SDag-Erling Smørgrav.Fa tm_isdst
222bc421551SDag-Erling Smørgravand
223bc421551SDag-Erling Smørgrav.Fa tm_gmtoff
224bc421551SDag-Erling Smørgravmembers are forced to zero by
225bc421551SDag-Erling Smørgrav.Fn timegm . )
226bc421551SDag-Erling Smørgrav.Pp
227bc421551SDag-Erling SmørgravOn successful completion, the values of the
228bc421551SDag-Erling Smørgrav.Fa tm_wday
229bc421551SDag-Erling Smørgravand
230bc421551SDag-Erling Smørgrav.Fa tm_yday
231bc421551SDag-Erling Smørgravcomponents of the structure are set appropriately, and the other components
232bc421551SDag-Erling Smørgravare set to represent the specified calendar time, but with their values
233bc421551SDag-Erling Smørgravforced to their normal ranges; the final value of
234bc421551SDag-Erling Smørgrav.Fa tm_mday
235bc421551SDag-Erling Smørgravis not set until
236bc421551SDag-Erling Smørgrav.Fa tm_mon
237bc421551SDag-Erling Smørgravand
238bc421551SDag-Erling Smørgrav.Fa tm_year
239bc421551SDag-Erling Smørgravare determined.
240bc421551SDag-Erling SmørgravThe
241bc421551SDag-Erling Smørgrav.Fn mktime
242bc421551SDag-Erling Smørgravfunction
243bc421551SDag-Erling Smørgravreturns the specified calendar time; if the calendar time cannot be
244*7534109dSDag-Erling Smørgravrepresented, it returns \-1 and sets
245*7534109dSDag-Erling Smørgrav.Xr errno 3
246*7534109dSDag-Erling Smørgravto an appropriate value.
247*7534109dSDag-Erling Smørgrav.Pp
248*7534109dSDag-Erling SmørgravNote that \-1 is a valid result (representing one second before
249*7534109dSDag-Erling Smørgravmidnight UTC on the evening of 31 December 1969), so this cannot be
250*7534109dSDag-Erling Smørgravrelied upon to indicate success or failure; instead,
251*7534109dSDag-Erling Smørgrav.Fa tm_wday
252*7534109dSDag-Erling Smørgravand / or
253*7534109dSDag-Erling Smørgrav.Fa tm_yday
254*7534109dSDag-Erling Smørgravshould be set to an out-of-bounds value (e.g. \-1) prior to calling
255*7534109dSDag-Erling Smørgrav.Fn mktime
256*7534109dSDag-Erling Smørgravor
257*7534109dSDag-Erling Smørgrav.Fn timegm
258*7534109dSDag-Erling Smørgravand checked after the call.
259bc421551SDag-Erling Smørgrav.Pp
260bc421551SDag-Erling SmørgravThe
261bc421551SDag-Erling Smørgrav.Fn difftime
2626f3c2f41SDag-Erling Smørgravfunction returns the difference in seconds between two time values,
2636f3c2f41SDag-Erling Smørgrav.Fa time1
2646f3c2f41SDag-Erling Smørgrav\-
2656f3c2f41SDag-Erling Smørgrav.Fa time0 .
266bc421551SDag-Erling Smørgrav.Pp
2676f3c2f41SDag-Erling SmørgravExternal declarations as well as the definition of
2686f3c2f41SDag-Erling Smørgrav.Vt struct tm
2696f3c2f41SDag-Erling Smørgravare in the
270bc421551SDag-Erling Smørgrav.In time.h
2716f3c2f41SDag-Erling Smørgravheader.
2726f3c2f41SDag-Erling SmørgravThe
2736f3c2f41SDag-Erling Smørgrav.Vt tm
2746f3c2f41SDag-Erling Smørgravstructure includes at least the following fields:
275bc421551SDag-Erling Smørgrav.Bd -literal -offset indent
276bc421551SDag-Erling Smørgravint tm_sec;	/* seconds (0 - 60) */
277bc421551SDag-Erling Smørgravint tm_min;	/* minutes (0 - 59) */
278bc421551SDag-Erling Smørgravint tm_hour;	/* hours (0 - 23) */
279bc421551SDag-Erling Smørgravint tm_mday;	/* day of month (1 - 31) */
280bc421551SDag-Erling Smørgravint tm_mon;	/* month of year (0 - 11) */
281bc421551SDag-Erling Smørgravint tm_year;	/* year \- 1900 */
282bc421551SDag-Erling Smørgravint tm_wday;	/* day of week (Sunday = 0) */
283bc421551SDag-Erling Smørgravint tm_yday;	/* day of year (0 - 365) */
284bc421551SDag-Erling Smørgravint tm_isdst;	/* is summer time in effect? */
285bc421551SDag-Erling Smørgravchar *tm_zone;	/* abbreviation of timezone name */
286bc421551SDag-Erling Smørgravlong tm_gmtoff;	/* offset from UTC in seconds */
287bc421551SDag-Erling Smørgrav.Ed
288bc421551SDag-Erling Smørgrav.Pp
289bc421551SDag-Erling SmørgravThe
290bc421551SDag-Erling Smørgrav.Fa tm_isdst
2916f3c2f41SDag-Erling Smørgravfield is non-zero if summer time is in effect.
292bc421551SDag-Erling Smørgrav.Pp
2936f3c2f41SDag-Erling SmørgravThe
294bc421551SDag-Erling Smørgrav.Fa tm_gmtoff
2956f3c2f41SDag-Erling Smørgravfield is the offset in seconds of the time represented from UTC,
2966f3c2f41SDag-Erling Smørgravwith positive values indicating a time zone ahead of UTC (east of the
2976f3c2f41SDag-Erling SmørgravPrime Meridian).
298bc421551SDag-Erling Smørgrav.Sh SEE ALSO
299bc421551SDag-Erling Smørgrav.Xr date 1 ,
300bc421551SDag-Erling Smørgrav.Xr clock_gettime 2 ,
301bc421551SDag-Erling Smørgrav.Xr gettimeofday 2 ,
302bc421551SDag-Erling Smørgrav.Xr getenv 3 ,
303bc421551SDag-Erling Smørgrav.Xr time 3 ,
304bc421551SDag-Erling Smørgrav.Xr tzset 3 ,
305bc421551SDag-Erling Smørgrav.Xr tzfile 5
306bc421551SDag-Erling Smørgrav.Sh STANDARDS
307bc421551SDag-Erling SmørgravThe
308bc421551SDag-Erling Smørgrav.Fn asctime ,
309bc421551SDag-Erling Smørgrav.Fn ctime ,
310bc421551SDag-Erling Smørgrav.Fn difftime ,
311bc421551SDag-Erling Smørgrav.Fn gmtime ,
312bc421551SDag-Erling Smørgrav.Fn localtime ,
313bc421551SDag-Erling Smørgravand
314bc421551SDag-Erling Smørgrav.Fn mktime
315bc421551SDag-Erling Smørgravfunctions conform to
316bc421551SDag-Erling Smørgrav.St -isoC ,
317bc421551SDag-Erling Smørgravand conform to
318bc421551SDag-Erling Smørgrav.St -p1003.1-96
319bc421551SDag-Erling Smørgravprovided the selected local timezone does not contain a leap-second table
320bc421551SDag-Erling Smørgrav(see
321bc421551SDag-Erling Smørgrav.Xr zic 8 ) .
322bc421551SDag-Erling Smørgrav.Pp
323bc421551SDag-Erling SmørgravThe
324bc421551SDag-Erling Smørgrav.Fn asctime_r ,
325bc421551SDag-Erling Smørgrav.Fn ctime_r ,
326bc421551SDag-Erling Smørgrav.Fn gmtime_r ,
327bc421551SDag-Erling Smørgravand
328bc421551SDag-Erling Smørgrav.Fn localtime_r
329bc421551SDag-Erling Smørgravfunctions are expected to conform to
330bc421551SDag-Erling Smørgrav.St -p1003.1-96
331bc421551SDag-Erling Smørgrav(again provided the selected local timezone does not contain a leap-second
332bc421551SDag-Erling Smørgravtable).
333bc421551SDag-Erling Smørgrav.Pp
334bc421551SDag-Erling SmørgravThe
335bc421551SDag-Erling Smørgrav.Fn timegm
336bc421551SDag-Erling Smørgravfunction is not specified by any standard; its function cannot be
337bc421551SDag-Erling Smørgravcompletely emulated using the standard functions described above.
338bc421551SDag-Erling Smørgrav.Sh HISTORY
339bc421551SDag-Erling SmørgravThis manual page is derived from
340bc421551SDag-Erling Smørgravthe time package contributed to Berkeley by
341bc421551SDag-Erling Smørgrav.An Arthur Olson
342bc421551SDag-Erling Smørgravand which appeared in
343bc421551SDag-Erling Smørgrav.Bx 4.3 .
344bc421551SDag-Erling Smørgrav.Pp
345bc421551SDag-Erling SmørgravThe functions
346bc421551SDag-Erling Smørgrav.Fn asctime ,
347bc421551SDag-Erling Smørgrav.Fn gmtime ,
348bc421551SDag-Erling Smørgravand
349bc421551SDag-Erling Smørgrav.Fn localtime
350bc421551SDag-Erling Smørgravfirst appeared in
351bc421551SDag-Erling Smørgrav.At v5 ,
352bc421551SDag-Erling Smørgrav.Fn difftime
353bc421551SDag-Erling Smørgravand
354bc421551SDag-Erling Smørgrav.Fn mktime
355bc421551SDag-Erling Smørgravin
356bc421551SDag-Erling Smørgrav.Bx 4.3 Reno ,
357bc421551SDag-Erling Smørgravand
358bc421551SDag-Erling Smørgrav.Fn timegm
359bc421551SDag-Erling Smørgravand
360bc421551SDag-Erling Smørgrav.Fn timelocal
361bc421551SDag-Erling Smørgravin SunOS 4.0.
362bc421551SDag-Erling Smørgrav.Pp
3636f3c2f41SDag-Erling SmørgravThe
364bc421551SDag-Erling Smørgrav.Fn asctime_r ,
365bc421551SDag-Erling Smørgrav.Fn ctime_r ,
3666f3c2f41SDag-Erling Smørgrav.Fn gmtime_r
367bc421551SDag-Erling Smørgravand
368bc421551SDag-Erling Smørgrav.Fn localtime_r
3696f3c2f41SDag-Erling Smørgravfunctions have been available since
370bc421551SDag-Erling Smørgrav.Fx 8.0 .
371bc421551SDag-Erling Smørgrav.Sh BUGS
372bc421551SDag-Erling SmørgravExcept for
373bc421551SDag-Erling Smørgrav.Fn difftime ,
374bc421551SDag-Erling Smørgrav.Fn mktime ,
375bc421551SDag-Erling Smørgravand the
376bc421551SDag-Erling Smørgrav.Fn \&_r
377bc421551SDag-Erling Smørgravvariants of the other functions,
378bc421551SDag-Erling Smørgravthese functions leave their result in an internal static object and return
379bc421551SDag-Erling Smørgrava pointer to that object.
380bc421551SDag-Erling SmørgravSubsequent calls to these
381bc421551SDag-Erling Smørgravfunction will modify the same object.
382bc421551SDag-Erling Smørgrav.Pp
383bc421551SDag-Erling SmørgravThe C Standard provides no mechanism for a program to modify its current
3846f3c2f41SDag-Erling Smørgravlocal timezone setting, and the POSIX-standard
385bc421551SDag-Erling Smørgravmethod is not reentrant.
386bc421551SDag-Erling Smørgrav(However, thread-safe implementations are provided
3876f3c2f41SDag-Erling Smørgravin the POSIX threaded environment.)
388bc421551SDag-Erling Smørgrav.Pp
389bc421551SDag-Erling SmørgravThe
390bc421551SDag-Erling Smørgrav.Va tm_zone
391bc421551SDag-Erling Smørgravfield of a returned
392bc421551SDag-Erling Smørgrav.Vt tm
393bc421551SDag-Erling Smørgravstructure points to a static array of characters,
394bc421551SDag-Erling Smørgravwhich will also be overwritten by any subsequent calls (as well as by
395bc421551SDag-Erling Smørgravsubsequent calls to
396a9a38deaSDag-Erling Smørgrav.Xr tzset 3 ) .
397bc421551SDag-Erling Smørgrav.Pp
398bc421551SDag-Erling SmørgravUse of the external variable
399bc421551SDag-Erling Smørgrav.Fa tzname
400bc421551SDag-Erling Smørgravis discouraged; the
401bc421551SDag-Erling Smørgrav.Fa tm_zone
402bc421551SDag-Erling Smørgraventry in the tm structure is preferred.
403