strftime.3c (2010 09)

s
strftime(3C) strftime(3C)
%OW The week number of the year (Monday as the first day of the week) using the locale’s
alternative numeric symbols.
%Oy The year (offset from %C
) in the locale’s alternative representation and using the locale’s
alternative symbols.
Field Width and Precision
An optional field width and precision specification can immediately follow the initial
% of a directive in
the following order:
[
-0]w The decimal digit string w specifies a minimum field width in which the result of the conver-
sion is right- or left-justified. It is right-justified (with space padding) by default. If the
optional flag
- is specified, it is left-justified with space padding on the right. If the optional
flag 0 is specified, it is right-justified and padded with zeros on the left.
.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 directive. 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:
HP-UX 11i Version 3: September 2010 − 3 − Hewlett-Packard Company 3