annotate doc/ctime.texi @ 6253:f194efd935e3

Note about ctime.
author Bruno Haible <bruno@clisp.org>
date Mon, 19 Sep 2005 15:46:53 +0000
parents
children adb21c293305
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
6253
f194efd935e3 Note about ctime.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
1 @node ctime
f194efd935e3 Note about ctime.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
2 @section ctime
f194efd935e3 Note about ctime.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
3 @findex ctime
f194efd935e3 Note about ctime.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
4
f194efd935e3 Note about ctime.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
5 The @code{ctime} function need not be reentrant, and consequently is
f194efd935e3 Note about ctime.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
6 not required to be thread safe. Implementations of @code{ctime}
f194efd935e3 Note about ctime.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
7 typically write the time stamp into static buffer. If two threads
f194efd935e3 Note about ctime.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
8 call @code{ctime} at roughly the same time, you might end up with the
f194efd935e3 Note about ctime.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
9 wrong date in one of the threads, or some undefined string. There is
f194efd935e3 Note about ctime.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
10 a re-entrant interface @code{ctime_r}, that take a pre-allocated
f194efd935e3 Note about ctime.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
11 buffer and length of the buffer, and return @code{NULL} on errors.
f194efd935e3 Note about ctime.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
12 The input buffer should be at least 26 bytes in size. The output
f194efd935e3 Note about ctime.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
13 string is locale-independent. However, years can have more than 4
f194efd935e3 Note about ctime.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
14 digits if @code{time_t} is sufficiently wide, so the length of the
f194efd935e3 Note about ctime.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
15 required output buffer is not easy to determine. Increasing the
f194efd935e3 Note about ctime.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
16 buffer size when @code{ctime_r} return @code{NULL} is not necessarily
f194efd935e3 Note about ctime.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
17 sufficient. The @code{NULL} return value could mean some other error
f194efd935e3 Note about ctime.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
18 condition, which will not go away by increasing the buffer size.
f194efd935e3 Note about ctime.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
19
f194efd935e3 Note about ctime.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
20 A more flexible function is @code{strftime}. However, note that it is
f194efd935e3 Note about ctime.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
21 locale dependent.