time.in.h revision 1.1.1.2 1 1.1 christos /* A more-standard <time.h>.
2 1.1 christos
3 1.1.1.2 christos Copyright (C) 2007-2022 Free Software Foundation, Inc.
4 1.1 christos
5 1.1.1.2 christos This file is free software: you can redistribute it and/or modify
6 1.1.1.2 christos it under the terms of the GNU Lesser General Public License as
7 1.1.1.2 christos published by the Free Software Foundation; either version 2.1 of the
8 1.1.1.2 christos License, or (at your option) any later version.
9 1.1 christos
10 1.1.1.2 christos This file is distributed in the hope that it will be useful,
11 1.1 christos but WITHOUT ANY WARRANTY; without even the implied warranty of
12 1.1 christos MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 1.1.1.2 christos GNU Lesser General Public License for more details.
14 1.1 christos
15 1.1.1.2 christos You should have received a copy of the GNU Lesser General Public License
16 1.1.1.2 christos along with this program. If not, see <https://www.gnu.org/licenses/>. */
17 1.1 christos
18 1.1 christos #if __GNUC__ >= 3
19 1.1 christos @PRAGMA_SYSTEM_HEADER@
20 1.1 christos #endif
21 1.1 christos @PRAGMA_COLUMNS@
22 1.1 christos
23 1.1 christos /* Don't get in the way of glibc when it includes time.h merely to
24 1.1 christos declare a few standard symbols, rather than to declare all the
25 1.1 christos symbols. (However, skip this for MinGW as it treats __need_time_t
26 1.1 christos incompatibly.) Also, Solaris 8 <time.h> eventually includes itself
27 1.1 christos recursively; if that is happening, just include the system <time.h>
28 1.1 christos without adding our own declarations. */
29 1.1 christos #if (((defined __need_time_t || defined __need_clock_t \
30 1.1 christos || defined __need_timespec) \
31 1.1 christos && !defined __MINGW32__) \
32 1.1 christos || defined _@GUARD_PREFIX@_TIME_H)
33 1.1 christos
34 1.1 christos # @INCLUDE_NEXT@ @NEXT_TIME_H@
35 1.1 christos
36 1.1 christos #else
37 1.1 christos
38 1.1 christos # define _@GUARD_PREFIX@_TIME_H
39 1.1 christos
40 1.1 christos /* mingw's <time.h> provides the functions asctime_r, ctime_r, gmtime_r,
41 1.1 christos localtime_r only if <unistd.h> or <pthread.h> has been included before. */
42 1.1 christos # if defined __MINGW32__
43 1.1 christos # include <unistd.h>
44 1.1 christos # endif
45 1.1 christos
46 1.1 christos # @INCLUDE_NEXT@ @NEXT_TIME_H@
47 1.1 christos
48 1.1 christos /* NetBSD 5.0 mis-defines NULL. */
49 1.1 christos # include <stddef.h>
50 1.1 christos
51 1.1 christos /* The definitions of _GL_FUNCDECL_RPL etc. are copied here. */
52 1.1 christos
53 1.1 christos /* The definition of _GL_ARG_NONNULL is copied here. */
54 1.1 christos
55 1.1 christos /* The definition of _GL_WARN_ON_USE is copied here. */
56 1.1 christos
57 1.1 christos /* Some systems don't define struct timespec (e.g., AIX 4.1).
58 1.1 christos Or they define it with the wrong member names or define it in <sys/time.h>
59 1.1 christos (e.g., FreeBSD circa 1997). Stock Mingw prior to 3.0 does not define it,
60 1.1 christos but the pthreads-win32 library defines it in <pthread.h>. */
61 1.1 christos # if ! @TIME_H_DEFINES_STRUCT_TIMESPEC@
62 1.1 christos # if @SYS_TIME_H_DEFINES_STRUCT_TIMESPEC@
63 1.1 christos # include <sys/time.h>
64 1.1 christos # elif @PTHREAD_H_DEFINES_STRUCT_TIMESPEC@
65 1.1 christos # include <pthread.h>
66 1.1 christos # elif @UNISTD_H_DEFINES_STRUCT_TIMESPEC@
67 1.1 christos # include <unistd.h>
68 1.1 christos # else
69 1.1 christos
70 1.1 christos # ifdef __cplusplus
71 1.1 christos extern "C" {
72 1.1 christos # endif
73 1.1 christos
74 1.1 christos # if !GNULIB_defined_struct_timespec
75 1.1 christos # undef timespec
76 1.1 christos # define timespec rpl_timespec
77 1.1 christos struct timespec
78 1.1 christos {
79 1.1 christos time_t tv_sec;
80 1.1 christos long int tv_nsec;
81 1.1 christos };
82 1.1 christos # define GNULIB_defined_struct_timespec 1
83 1.1 christos # endif
84 1.1 christos
85 1.1 christos # ifdef __cplusplus
86 1.1 christos }
87 1.1 christos # endif
88 1.1 christos
89 1.1 christos # endif
90 1.1 christos # endif
91 1.1 christos
92 1.1 christos # if !GNULIB_defined_struct_time_t_must_be_integral
93 1.1 christos /* https://pubs.opengroup.org/onlinepubs/9699919799/basedefs/sys_types.h.html
94 1.1 christos requires time_t to be an integer type, even though C99 permits floating
95 1.1 christos point. We don't know of any implementation that uses floating
96 1.1 christos point, and it is much easier to write code that doesn't have to
97 1.1 christos worry about that corner case, so we force the issue. */
98 1.1 christos struct __time_t_must_be_integral {
99 1.1 christos unsigned int __floating_time_t_unsupported : (time_t) 1;
100 1.1 christos };
101 1.1 christos # define GNULIB_defined_struct_time_t_must_be_integral 1
102 1.1 christos # endif
103 1.1 christos
104 1.1.1.2 christos /* Define TIME_UTC, a positive integer constant used for timespec_get(). */
105 1.1.1.2 christos # if ! @TIME_H_DEFINES_TIME_UTC@
106 1.1.1.2 christos # if !GNULIB_defined_TIME_UTC
107 1.1.1.2 christos # define TIME_UTC 1
108 1.1.1.2 christos # define GNULIB_defined_TIME_UTC 1
109 1.1.1.2 christos # endif
110 1.1.1.2 christos # endif
111 1.1.1.2 christos
112 1.1.1.2 christos /* Set *TS to the current time, and return BASE.
113 1.1.1.2 christos Upon failure, return 0. */
114 1.1.1.2 christos # if @GNULIB_TIMESPEC_GET@
115 1.1.1.2 christos # if ! @HAVE_TIMESPEC_GET@
116 1.1.1.2 christos _GL_FUNCDECL_SYS (timespec_get, int, (struct timespec *ts, int base)
117 1.1.1.2 christos _GL_ARG_NONNULL ((1)));
118 1.1.1.2 christos # endif
119 1.1.1.2 christos _GL_CXXALIAS_SYS (timespec_get, int, (struct timespec *ts, int base));
120 1.1.1.2 christos _GL_CXXALIASWARN (timespec_get);
121 1.1.1.2 christos # endif
122 1.1.1.2 christos
123 1.1.1.2 christos /* Set *TS to the current time resolution, and return BASE.
124 1.1.1.2 christos Upon failure, return 0. */
125 1.1.1.2 christos # if @GNULIB_TIMESPEC_GETRES@
126 1.1.1.2 christos # if ! @HAVE_TIMESPEC_GETRES@
127 1.1.1.2 christos _GL_FUNCDECL_SYS (timespec_getres, int, (struct timespec *ts, int base)
128 1.1.1.2 christos _GL_ARG_NONNULL ((1)));
129 1.1.1.2 christos # endif
130 1.1.1.2 christos _GL_CXXALIAS_SYS (timespec_getres, int, (struct timespec *ts, int base));
131 1.1.1.2 christos _GL_CXXALIASWARN (timespec_getres);
132 1.1.1.2 christos # endif
133 1.1.1.2 christos
134 1.1 christos /* Sleep for at least RQTP seconds unless interrupted, If interrupted,
135 1.1 christos return -1 and store the remaining time into RMTP. See
136 1.1 christos <https://pubs.opengroup.org/onlinepubs/9699919799/functions/nanosleep.html>. */
137 1.1 christos # if @GNULIB_NANOSLEEP@
138 1.1 christos # if @REPLACE_NANOSLEEP@
139 1.1 christos # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
140 1.1 christos # define nanosleep rpl_nanosleep
141 1.1 christos # endif
142 1.1 christos _GL_FUNCDECL_RPL (nanosleep, int,
143 1.1 christos (struct timespec const *__rqtp, struct timespec *__rmtp)
144 1.1 christos _GL_ARG_NONNULL ((1)));
145 1.1 christos _GL_CXXALIAS_RPL (nanosleep, int,
146 1.1 christos (struct timespec const *__rqtp, struct timespec *__rmtp));
147 1.1 christos # else
148 1.1 christos # if ! @HAVE_NANOSLEEP@
149 1.1 christos _GL_FUNCDECL_SYS (nanosleep, int,
150 1.1 christos (struct timespec const *__rqtp, struct timespec *__rmtp)
151 1.1 christos _GL_ARG_NONNULL ((1)));
152 1.1 christos # endif
153 1.1 christos _GL_CXXALIAS_SYS (nanosleep, int,
154 1.1 christos (struct timespec const *__rqtp, struct timespec *__rmtp));
155 1.1 christos # endif
156 1.1 christos _GL_CXXALIASWARN (nanosleep);
157 1.1 christos # endif
158 1.1 christos
159 1.1 christos /* Initialize time conversion information. */
160 1.1 christos # if @GNULIB_TZSET@
161 1.1 christos # if @REPLACE_TZSET@
162 1.1 christos # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
163 1.1 christos # undef tzset
164 1.1 christos # define tzset rpl_tzset
165 1.1 christos # endif
166 1.1 christos _GL_FUNCDECL_RPL (tzset, void, (void));
167 1.1 christos _GL_CXXALIAS_RPL (tzset, void, (void));
168 1.1.1.2 christos # elif defined _WIN32 && !defined __CYGWIN__
169 1.1.1.2 christos # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
170 1.1.1.2 christos # undef tzset
171 1.1.1.2 christos # define tzset _tzset
172 1.1.1.2 christos # endif
173 1.1.1.2 christos _GL_CXXALIAS_MDA (tzset, void, (void));
174 1.1 christos # else
175 1.1.1.2 christos _GL_CXXALIAS_SYS (tzset, void, (void));
176 1.1.1.2 christos # endif
177 1.1.1.2 christos _GL_CXXALIASWARN (tzset);
178 1.1.1.2 christos # elif @GNULIB_MDA_TZSET@
179 1.1.1.2 christos /* On native Windows, map 'tzset' to '_tzset', so that -loldnames is not
180 1.1.1.2 christos required. In C++ with GNULIB_NAMESPACE, avoid differences between
181 1.1.1.2 christos platforms by defining GNULIB_NAMESPACE::tzset always. */
182 1.1.1.2 christos # if defined _WIN32 && !defined __CYGWIN__
183 1.1.1.2 christos # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
184 1.1.1.2 christos # undef tzset
185 1.1.1.2 christos # define tzset _tzset
186 1.1 christos # endif
187 1.1.1.2 christos _GL_CXXALIAS_MDA (tzset, void, (void));
188 1.1.1.2 christos # else
189 1.1 christos _GL_CXXALIAS_SYS (tzset, void, (void));
190 1.1 christos # endif
191 1.1 christos _GL_CXXALIASWARN (tzset);
192 1.1 christos # endif
193 1.1 christos
194 1.1 christos /* Return the 'time_t' representation of TP and normalize TP. */
195 1.1 christos # if @GNULIB_MKTIME@
196 1.1 christos # if @REPLACE_MKTIME@
197 1.1 christos # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
198 1.1 christos # define mktime rpl_mktime
199 1.1 christos # endif
200 1.1 christos _GL_FUNCDECL_RPL (mktime, time_t, (struct tm *__tp) _GL_ARG_NONNULL ((1)));
201 1.1 christos _GL_CXXALIAS_RPL (mktime, time_t, (struct tm *__tp));
202 1.1 christos # else
203 1.1 christos _GL_CXXALIAS_SYS (mktime, time_t, (struct tm *__tp));
204 1.1 christos # endif
205 1.1 christos # if __GLIBC__ >= 2
206 1.1 christos _GL_CXXALIASWARN (mktime);
207 1.1 christos # endif
208 1.1 christos # endif
209 1.1 christos
210 1.1 christos /* Convert TIMER to RESULT, assuming local time and UTC respectively. See
211 1.1 christos <https://pubs.opengroup.org/onlinepubs/9699919799/functions/localtime_r.html> and
212 1.1 christos <https://pubs.opengroup.org/onlinepubs/9699919799/functions/gmtime_r.html>. */
213 1.1 christos # if @GNULIB_TIME_R@
214 1.1 christos # if @REPLACE_LOCALTIME_R@
215 1.1 christos # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
216 1.1 christos # undef localtime_r
217 1.1 christos # define localtime_r rpl_localtime_r
218 1.1 christos # endif
219 1.1 christos _GL_FUNCDECL_RPL (localtime_r, struct tm *, (time_t const *restrict __timer,
220 1.1 christos struct tm *restrict __result)
221 1.1 christos _GL_ARG_NONNULL ((1, 2)));
222 1.1 christos _GL_CXXALIAS_RPL (localtime_r, struct tm *, (time_t const *restrict __timer,
223 1.1 christos struct tm *restrict __result));
224 1.1 christos # else
225 1.1 christos # if ! @HAVE_DECL_LOCALTIME_R@
226 1.1 christos _GL_FUNCDECL_SYS (localtime_r, struct tm *, (time_t const *restrict __timer,
227 1.1 christos struct tm *restrict __result)
228 1.1 christos _GL_ARG_NONNULL ((1, 2)));
229 1.1 christos # endif
230 1.1 christos _GL_CXXALIAS_SYS (localtime_r, struct tm *, (time_t const *restrict __timer,
231 1.1 christos struct tm *restrict __result));
232 1.1 christos # endif
233 1.1 christos # if @HAVE_DECL_LOCALTIME_R@
234 1.1 christos _GL_CXXALIASWARN (localtime_r);
235 1.1 christos # endif
236 1.1 christos # if @REPLACE_LOCALTIME_R@
237 1.1 christos # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
238 1.1 christos # undef gmtime_r
239 1.1 christos # define gmtime_r rpl_gmtime_r
240 1.1 christos # endif
241 1.1 christos _GL_FUNCDECL_RPL (gmtime_r, struct tm *, (time_t const *restrict __timer,
242 1.1 christos struct tm *restrict __result)
243 1.1 christos _GL_ARG_NONNULL ((1, 2)));
244 1.1 christos _GL_CXXALIAS_RPL (gmtime_r, struct tm *, (time_t const *restrict __timer,
245 1.1 christos struct tm *restrict __result));
246 1.1 christos # else
247 1.1 christos # if ! @HAVE_DECL_LOCALTIME_R@
248 1.1 christos _GL_FUNCDECL_SYS (gmtime_r, struct tm *, (time_t const *restrict __timer,
249 1.1 christos struct tm *restrict __result)
250 1.1 christos _GL_ARG_NONNULL ((1, 2)));
251 1.1 christos # endif
252 1.1 christos _GL_CXXALIAS_SYS (gmtime_r, struct tm *, (time_t const *restrict __timer,
253 1.1 christos struct tm *restrict __result));
254 1.1 christos # endif
255 1.1 christos # if @HAVE_DECL_LOCALTIME_R@
256 1.1 christos _GL_CXXALIASWARN (gmtime_r);
257 1.1 christos # endif
258 1.1 christos # endif
259 1.1 christos
260 1.1 christos /* Convert TIMER to RESULT, assuming local time and UTC respectively. See
261 1.1 christos <https://pubs.opengroup.org/onlinepubs/9699919799/functions/localtime.html> and
262 1.1 christos <https://pubs.opengroup.org/onlinepubs/9699919799/functions/gmtime.html>. */
263 1.1 christos # if @GNULIB_LOCALTIME@ || @REPLACE_LOCALTIME@
264 1.1 christos # if @REPLACE_LOCALTIME@
265 1.1 christos # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
266 1.1 christos # undef localtime
267 1.1 christos # define localtime rpl_localtime
268 1.1 christos # endif
269 1.1 christos _GL_FUNCDECL_RPL (localtime, struct tm *, (time_t const *__timer)
270 1.1 christos _GL_ARG_NONNULL ((1)));
271 1.1 christos _GL_CXXALIAS_RPL (localtime, struct tm *, (time_t const *__timer));
272 1.1 christos # else
273 1.1 christos _GL_CXXALIAS_SYS (localtime, struct tm *, (time_t const *__timer));
274 1.1 christos # endif
275 1.1 christos # if __GLIBC__ >= 2
276 1.1 christos _GL_CXXALIASWARN (localtime);
277 1.1 christos # endif
278 1.1 christos # endif
279 1.1 christos
280 1.1 christos # if 0 || @REPLACE_GMTIME@
281 1.1 christos # if @REPLACE_GMTIME@
282 1.1 christos # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
283 1.1 christos # undef gmtime
284 1.1 christos # define gmtime rpl_gmtime
285 1.1 christos # endif
286 1.1 christos _GL_FUNCDECL_RPL (gmtime, struct tm *, (time_t const *__timer)
287 1.1 christos _GL_ARG_NONNULL ((1)));
288 1.1 christos _GL_CXXALIAS_RPL (gmtime, struct tm *, (time_t const *__timer));
289 1.1 christos # else
290 1.1 christos _GL_CXXALIAS_SYS (gmtime, struct tm *, (time_t const *__timer));
291 1.1 christos # endif
292 1.1 christos _GL_CXXALIASWARN (gmtime);
293 1.1 christos # endif
294 1.1 christos
295 1.1 christos /* Parse BUF as a timestamp, assuming FORMAT specifies its layout, and store
296 1.1 christos the resulting broken-down time into TM. See
297 1.1 christos <https://pubs.opengroup.org/onlinepubs/9699919799/functions/strptime.html>. */
298 1.1 christos # if @GNULIB_STRPTIME@
299 1.1 christos # if ! @HAVE_STRPTIME@
300 1.1 christos _GL_FUNCDECL_SYS (strptime, char *, (char const *restrict __buf,
301 1.1 christos char const *restrict __format,
302 1.1 christos struct tm *restrict __tm)
303 1.1 christos _GL_ARG_NONNULL ((1, 2, 3)));
304 1.1 christos # endif
305 1.1 christos _GL_CXXALIAS_SYS (strptime, char *, (char const *restrict __buf,
306 1.1 christos char const *restrict __format,
307 1.1 christos struct tm *restrict __tm));
308 1.1 christos _GL_CXXALIASWARN (strptime);
309 1.1 christos # endif
310 1.1 christos
311 1.1 christos /* Convert *TP to a date and time string. See
312 1.1 christos <https://pubs.opengroup.org/onlinepubs/9699919799/functions/ctime.html>. */
313 1.1 christos # if @GNULIB_CTIME@
314 1.1 christos # if @REPLACE_CTIME@
315 1.1 christos # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
316 1.1 christos # define ctime rpl_ctime
317 1.1 christos # endif
318 1.1 christos _GL_FUNCDECL_RPL (ctime, char *, (time_t const *__tp)
319 1.1 christos _GL_ARG_NONNULL ((1)));
320 1.1 christos _GL_CXXALIAS_RPL (ctime, char *, (time_t const *__tp));
321 1.1 christos # else
322 1.1 christos _GL_CXXALIAS_SYS (ctime, char *, (time_t const *__tp));
323 1.1 christos # endif
324 1.1 christos # if __GLIBC__ >= 2
325 1.1 christos _GL_CXXALIASWARN (ctime);
326 1.1 christos # endif
327 1.1 christos # endif
328 1.1 christos
329 1.1 christos /* Convert *TP to a date and time string. See
330 1.1 christos <https://pubs.opengroup.org/onlinepubs/9699919799/functions/strftime.html>. */
331 1.1 christos # if @GNULIB_STRFTIME@
332 1.1 christos # if @REPLACE_STRFTIME@
333 1.1 christos # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
334 1.1 christos # define strftime rpl_strftime
335 1.1 christos # endif
336 1.1 christos _GL_FUNCDECL_RPL (strftime, size_t,
337 1.1 christos (char *restrict __buf, size_t __bufsize,
338 1.1 christos const char *restrict __fmt, const struct tm *restrict __tp)
339 1.1 christos _GL_ARG_NONNULL ((1, 3, 4)));
340 1.1 christos _GL_CXXALIAS_RPL (strftime, size_t,
341 1.1 christos (char *restrict __buf, size_t __bufsize,
342 1.1 christos const char *restrict __fmt, const struct tm *restrict __tp));
343 1.1 christos # else
344 1.1 christos _GL_CXXALIAS_SYS (strftime, size_t,
345 1.1 christos (char *restrict __buf, size_t __bufsize,
346 1.1 christos const char *restrict __fmt, const struct tm *restrict __tp));
347 1.1 christos # endif
348 1.1 christos # if __GLIBC__ >= 2
349 1.1 christos _GL_CXXALIASWARN (strftime);
350 1.1 christos # endif
351 1.1 christos # endif
352 1.1 christos
353 1.1 christos # if defined _GNU_SOURCE && @GNULIB_TIME_RZ@ && ! @HAVE_TIMEZONE_T@
354 1.1.1.2 christos /* Functions that use a first-class time zone data type, instead of
355 1.1.1.2 christos relying on an implicit global time zone.
356 1.1.1.2 christos Inspired by NetBSD. */
357 1.1.1.2 christos
358 1.1.1.2 christos /* Represents a time zone.
359 1.1.1.2 christos (timezone_t) NULL stands for UTC. */
360 1.1 christos typedef struct tm_zone *timezone_t;
361 1.1.1.2 christos
362 1.1.1.2 christos /* tzalloc (name)
363 1.1.1.2 christos Returns a time zone object for the given time zone NAME. This object
364 1.1.1.2 christos represents the time zone that other functions would use it the TZ
365 1.1.1.2 christos environment variable was set to NAME.
366 1.1.1.2 christos If NAME is NULL, the result represents the time zone that other functions
367 1.1.1.2 christos would use it the TZ environment variable was unset.
368 1.1.1.2 christos May return NULL if NAME is invalid (this is platform dependent) or
369 1.1.1.2 christos upon memory allocation failure. */
370 1.1 christos _GL_FUNCDECL_SYS (tzalloc, timezone_t, (char const *__name));
371 1.1 christos _GL_CXXALIAS_SYS (tzalloc, timezone_t, (char const *__name));
372 1.1.1.2 christos
373 1.1.1.2 christos /* tzfree (tz)
374 1.1.1.2 christos Frees a time zone object.
375 1.1.1.2 christos The argument must have been returned by tzalloc(). */
376 1.1 christos _GL_FUNCDECL_SYS (tzfree, void, (timezone_t __tz));
377 1.1 christos _GL_CXXALIAS_SYS (tzfree, void, (timezone_t __tz));
378 1.1.1.2 christos
379 1.1.1.2 christos /* localtime_rz (tz, &t, &result)
380 1.1.1.2 christos Converts an absolute time T to a broken-down time RESULT, assuming the
381 1.1.1.2 christos time zone TZ.
382 1.1.1.2 christos This function is like 'localtime_r', but relies on the argument TZ instead
383 1.1.1.2 christos of an implicit global time zone. */
384 1.1 christos _GL_FUNCDECL_SYS (localtime_rz, struct tm *,
385 1.1 christos (timezone_t __tz, time_t const *restrict __timer,
386 1.1 christos struct tm *restrict __result) _GL_ARG_NONNULL ((2, 3)));
387 1.1 christos _GL_CXXALIAS_SYS (localtime_rz, struct tm *,
388 1.1 christos (timezone_t __tz, time_t const *restrict __timer,
389 1.1 christos struct tm *restrict __result));
390 1.1.1.2 christos
391 1.1.1.2 christos /* mktime_z (tz, &tm)
392 1.1.1.2 christos Normalizes the broken-down time TM and converts it to an absolute time,
393 1.1.1.2 christos assuming the time zone TZ. Returns the absolute time.
394 1.1.1.2 christos This function is like 'mktime', but relies on the argument TZ instead
395 1.1.1.2 christos of an implicit global time zone. */
396 1.1 christos _GL_FUNCDECL_SYS (mktime_z, time_t,
397 1.1.1.2 christos (timezone_t __tz, struct tm *restrict __tm)
398 1.1 christos _GL_ARG_NONNULL ((2)));
399 1.1 christos _GL_CXXALIAS_SYS (mktime_z, time_t,
400 1.1.1.2 christos (timezone_t __tz, struct tm *restrict __tm));
401 1.1.1.2 christos
402 1.1.1.2 christos /* Time zone abbreviation strings (returned by 'localtime_rz' or 'mktime_z'
403 1.1.1.2 christos in the 'tm_zone' member of 'struct tm') are valid as long as
404 1.1.1.2 christos - the 'struct tm' argument is not destroyed or overwritten,
405 1.1.1.2 christos and
406 1.1.1.2 christos - the 'timezone_t' argument is not freed through tzfree(). */
407 1.1.1.2 christos
408 1.1 christos # endif
409 1.1 christos
410 1.1 christos /* Convert TM to a time_t value, assuming UTC. */
411 1.1 christos # if @GNULIB_TIMEGM@
412 1.1 christos # if @REPLACE_TIMEGM@
413 1.1 christos # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
414 1.1 christos # undef timegm
415 1.1 christos # define timegm rpl_timegm
416 1.1 christos # endif
417 1.1 christos _GL_FUNCDECL_RPL (timegm, time_t, (struct tm *__tm) _GL_ARG_NONNULL ((1)));
418 1.1 christos _GL_CXXALIAS_RPL (timegm, time_t, (struct tm *__tm));
419 1.1 christos # else
420 1.1 christos # if ! @HAVE_TIMEGM@
421 1.1 christos _GL_FUNCDECL_SYS (timegm, time_t, (struct tm *__tm) _GL_ARG_NONNULL ((1)));
422 1.1 christos # endif
423 1.1 christos _GL_CXXALIAS_SYS (timegm, time_t, (struct tm *__tm));
424 1.1 christos # endif
425 1.1 christos _GL_CXXALIASWARN (timegm);
426 1.1 christos # endif
427 1.1 christos
428 1.1 christos /* Encourage applications to avoid unsafe functions that can overrun
429 1.1 christos buffers when given outlandish struct tm values. Portable
430 1.1 christos applications should use strftime (or even sprintf) instead. */
431 1.1 christos # if defined GNULIB_POSIXCHECK
432 1.1 christos # undef asctime
433 1.1 christos _GL_WARN_ON_USE (asctime, "asctime can overrun buffers in some cases - "
434 1.1 christos "better use strftime (or even sprintf) instead");
435 1.1 christos # endif
436 1.1 christos # if defined GNULIB_POSIXCHECK
437 1.1 christos # undef asctime_r
438 1.1.1.2 christos _GL_WARN_ON_USE (asctime_r, "asctime_r can overrun buffers in some cases - "
439 1.1 christos "better use strftime (or even sprintf) instead");
440 1.1 christos # endif
441 1.1 christos # if defined GNULIB_POSIXCHECK
442 1.1 christos # undef ctime
443 1.1.1.2 christos _GL_WARN_ON_USE (ctime, "ctime can overrun buffers in some cases - "
444 1.1 christos "better use strftime (or even sprintf) instead");
445 1.1 christos # endif
446 1.1 christos # if defined GNULIB_POSIXCHECK
447 1.1 christos # undef ctime_r
448 1.1.1.2 christos _GL_WARN_ON_USE (ctime_r, "ctime_r can overrun buffers in some cases - "
449 1.1 christos "better use strftime (or even sprintf) instead");
450 1.1 christos # endif
451 1.1 christos
452 1.1 christos #endif
453