HP-UX Reference (11i v2 03/08) - 3 Library Functions N-Z (vol 7)
s
strftime(3C) strftime(3C)
.p The decimal digit string p specifies the minimum number of digits to appear for the
d, H,
I, j, m, M
, o, S, U, w, W, y and Y directives, and the maximum number of bytes to be used
from the
a, A, b,
B, c, D, E, F, h, n, N, p
, r, t, T, x, X, z, Z, and %
directives. In the first
case, if a directive supplies fewer digits than specified by the precision, it will be
expanded with leading zeros. In the second case, if a directive supplies more bytes than
specified by the precision, excess bytes will truncated on the right.
If no field width or precision is specified for a
d, H, I, m, M, S
, U, W, y,orj directive, a default of .2 is
used for all but
j for which
.3 is used.
EXTERNAL INFLUENCES
Locale
The
LC_TIME category determines the characters to be substituted for those directives described above
as being from the locale.
The
LC_CTYPE category determines the interpretation of the bytes within format as single and/or multi-
byte characters.
The
LC_NUMERIC category determines the characters used to form numbers for those directives that pro-
duce numbers in the output. If ALT_DIGITS (see langinfo(5)) is defined for the locale, the characters so
specified are used in place of the default ASCII characters. If both
ALT_DIGITS and ALT_DIGIT is
defined for the locale,
ALT_DIGITS will take precedence over ALT_DIGIT.
Environment Variables
TZ determines the time zone name substituted for the %Z and %z directives. The time zone name is
determined by calling the function tzset() which sets the external variable tzname (see ctime(3C)).
International Code Set Support
Single- and multi-byte character code sets are supported.
RETURN VALUE
If the total number of resulting bytes including the terminating null byte is not more than maxsize,
strftime() returns the number of bytes placed into the array pointed to by s, not including the ter-
minating null byte. Otherwise, zero is returned and the contents of the array are indeterminate.
EXAMPLES
If the timeptr argument contains the following values:
timeptr->tm_sec = 4;
timeptr->tm_min = 9;
timeptr->tm_hour = 15;
timeptr->tm_mday = 4;
timeptr->tm_mon = 6;
timeptr->tm_year = 88;
timeptr->tm_wday = 1;
timeptr->tm_yday = 185;
timeptr->tm_isdst = 1;
the following combinations of the LC_TIME category and format strings produce the indicated output:
LC_TIME Format String Output
en_US.roman8 %x Mon, Jul 4, 1988
de_De.roman8 %x Mo., 4. Juli 1988
en_US.roman8 %X 03:09:04 PM
fr_FR.roman8 %X 15h09 04
any* %H:%M:%S 15:09:04
any* %.1H:%.1M:%.1S 15:9:4
any* %2.1H:%-3M:%03.1S 15:9 :004
* The directives used in these examples are not affected by the
LC_TIME category of the locale.
WARNINGS
If the arguments s and format are defined such that they overlap, the behavior is undefined.
The function tzset() is called upon every invocation of strftime() (whether or not the time zone
name is copied to the output array).
Section 3−−990 Hewlett-Packard Company − 3 − HP-UX 11i Version 2: August 2003