strftime [ HP C/iX Library Reference Manual ] MPE/iX 5.0 Documentation
HP C/iX Library Reference Manual
strftime
Creates a formatted time string.
Syntax
#include <time.h>
size_t strftime(char *s, size_t maxsize,
const char *format,
const struct tm *timeptr);
Parameters
s A pointer to a character array to which the function
returns a formatted character string.
maxsize The size of the character array.
format A pointer to an array containing conversion specifications
and ordinary multibyte characters to be inserted the
string.
timeptr A pointer to a tm variable in broken-down time format.
Return Values
x A value of type size_t indicating the number of characters
placed into the array pointed to by s.
0 The resulting formatted character string is greater than
maxsize, and s is indeterminate.
Description
This function places characters into the array pointed to by s, which is
controlled by the string pointed to by format. This string consists of
zero or more conversion specifications and ordinary multibyte characters.
A conversion specification consists of a % followed by a character that
determines the conversion specification's behavior.
All ordinary multibyte characters (including the terminating null
character) are copied unchanged into the array. If copying occurs
between objects that overlap, the behavior is undefined. No more than
maxsize characters are placed into the array.
Each conversion specification is replaced by appropriate characters, as
described below. These characters are determined by the program's locale
as determined by lc_time and by the values contained in the structure
pointed to by timeptr.
%a is replaced by the locale's abbreviated weekday name.
%A is replaced by the locale's full weekday name.
%b is replaced by the locale's abbreviated month name.
%B is replaced by the locale's full month name.
%c is replaced by the locale's appropriate date and time
representation.
%d is replaced by the day of the month as a decimal number
(01-31).[REV BEG]
%e is replaced by the day of the month as a decimal number (1-31
in a two-digit right-justified field with leading <space>
fill).[REV END]
%H is replaced by the hour (24-hour clock) as a decimal number
(00-23).
%I is replaced by the hour (12-hour clock) as a decimal number
(01-12).
%j is replaced by the day of the year as a decimal number
(001-366).
%m is replaced by the month as a decimal number (01-12).
%M is replaced by the minute as a decimal number (00-59).
%p is replaced by the locale's equivalent of either AM or PM.
%S is replaced by the second as a decimal number (00-61).
%U is replaced by the week number of the year (Sunday as the first
day of the week) as a decimal number (00-53).
%w is replaced by the weekday as a decimal number [0 (Sunday)-6].
%W is replaced by the week number of the year (Monday as the first
day of week 1) as decimal number (00-53).
%x is replaced by the locale's appropriate date representation.
%X is replaced by the locale's appropriate time representation.
%y is replaced by the year without century as a decimal number
(00-99).
%Y is replaced by the year with century as a decimal number.
%Z is replaced by the time zone name, or by no character if no
time zone is determinable.
%% is replaced by %.
The behavior is undefined for any conversion specification not described
above.
If the total number of resulting characters (including the terminating
null character) is not more than maxsize, strftime returns the number of
characters placed into the array pointed to by s (not including the
terminating null character). Otherwise, zero is returned and the array
contents are indeterminate.
See Also
ANSI C 4.12.3.5, POSIX.1 8.1
MPE/iX 5.0 Documentation