strftime.3: Clarify details of return value

Signed-off-by: Michael Kerrisk <mtk.manpages@gmail.com>
This commit is contained in:
Michael Kerrisk 2013-06-28 04:19:55 +02:00
parent 6f78750b5e
commit 511b30188b
1 changed files with 19 additions and 10 deletions

View File

@ -34,7 +34,7 @@
.\" 2005-11-22 mtk, added Glibc Notes covering optional 'flag' and
.\" 'width' components of conversion specifications.
.\"
.TH STRFTIME 3 2012-05-10 "GNU" "Linux Programmer's Manual"
.TH STRFTIME 3 2013-06-28 "GNU" "Linux Programmer's Manual"
.SH NAME
strftime \- format date and time
.SH SYNOPSIS
@ -325,24 +325,33 @@ is defined in
See also
.BR ctime (3).
.SH RETURN VALUE
The
Provided that the result string,
including the terminating null byte, does not exceed
.I max
bytes,
.BR strftime ()
function returns the number of bytes placed
in the array
.IR s ,
not including the terminating null byte,
provided the string, including the terminating null byte, fits.
Otherwise, it returns 0, and the contents of the array are undefined.
returns the number of bytes (excluding the terminating null byte)
placed in the array
.IR s .
If the length of the result string (including the terminating null byte)
would exceed
.I max
bytes, then
.BR strftime ()
returns 0, and the contents of the array are undefined.
(This behavior applies since at least libc 4.4.4;
very old versions of libc, such as libc 4.4.1,
would return
.I max
if the array was too small.)
.LP
Note that the return value 0 does not necessarily indicate an error;
for example, in many locales
Note that the return value 0 does not necessarily indicate an error.
For example, in many locales
.B %p
yields an empty string.
An empty
.I format
string will likewise yield an empty string.
.SH ENVIRONMENT
The environment variables
.B TZ