poll tests: Avoid test failure on BSD and Solaris systems.
[gnulib.git] / doc / posix-functions / ctime_r.texi
blobca937ac45b3b891c1bc0569e94329d6f17f0be9f
1 @node ctime_r
2 @section @code{ctime_r}
3 @findex ctime_r
5 POSIX specification:@* @url{https://pubs.opengroup.org/onlinepubs/9699919799/functions/ctime_r.html}
7 Gnulib module: extensions
9 Portability problems fixed by Gnulib:
10 @itemize
11 @item
12 This function has an incompatible declaration on some platforms:
13 Solaris 11.4 (when @code{_POSIX_PTHREAD_SEMANTICS} is not defined).
14 @end itemize
16 Portability problems not fixed by Gnulib:
17 @itemize
18 @item
19 This function is missing on some platforms:
20 mingw, MSVC 14.
21 @item
22 This function may put more than 26 bytes into the argument buffer if an
23 invalid year is passed.
24 @end itemize
26 @code{ctime_r} takes a pre-allocated buffer and length of the buffer,
27 and returns @code{NULL} on errors.
28 The input buffer should be at least 26 bytes in size.  The output
29 string is locale-independent.  However, years can have more than 4
30 digits if @code{time_t} is sufficiently wide, so the length of the
31 required output buffer is not easy to determine.  Increasing the
32 buffer size when @code{ctime_r} returns @code{NULL} is not necessarily
33 sufficient.  The @code{NULL} return value could mean some other error
34 condition, which will not go away by increasing the buffer size.
36 A more flexible function is @code{strftime}.  However, note that it is
37 locale dependent.