strftime(3) — Subroutines
OSF
NAME
strftime − Converts date and time to string
LIBRARY
Standard C Library (libc.a)
SYNOPSIS
#include <time.h> size_t strftime(
char ∗s,
size_t maxsize,
const char ∗format,
const struct tm ∗timeptr) ;
PARAMETERS
sPoints to the array containing the specified date and time string.
maxsizeSpecifies the maximum number of characters to be written to the array pointed to by the s parameter.
formatPoints to a sequence of control characters (refer to the foregoing list) that specify the format of the date and time string pointed to by the s parameter.
timeptrPoints to a type tm structure that contains broken-down time information.
DESCRIPTION
The strftime() function places characters into the array pointed to by the s parameter as controlled by the string pointed to by the format parameter. The string pointed to by the format parameter is a multibyte character sequence, beginning and ending in its initial shift state.
Local time zone information is used as though the strftime() function called the tzset() function. Time information used in this subroutine is fetched from space containing type tm structure data, which is defined in the time.h include file. The type tm structure must contain the time information used by this subroutine to construct the time and date string.
The format string consists of zero or more conversion specifications and ordinary multibyte characters. A conversion specification consists of a % (percent) character followed by a character that determines how the conversion specification constructs the formatted string.
All ordinary multibyte characters (including the terminating null character) are copied unchanged into the s array. When copying between objects that overlap takes place, behavior of this function is undefined. No more than the number of characters specified by the maxsize parameter are written to the array. Each conversion specification is replaced by appropriate characters as described in the following list. The appropriate characters are determined by the LC_TIME category of the current locale and by values specified by the type tm structure pointed to by the timeptr parameter.
%aIs replaced by the abbreviated weekday name appropriate for the locale
%AIs replaced by the full weekday name appropriate for the locale
%bIs replaced by the abbreviated month name appropriate for the locale
%BIs replaced by the full month name appropriate for the locale
%cIs replaced by the date and time representation appropriate for the locale
%dIs replaced by the day of the month as a decimal number [01, 31]
%DIs replaced by the date (%m/%d/%y)
%hIs replaced by the abbreviated month name appropriate for the locale
%HIs replaced by the hour (24-hour clock) as a decimal number [00, 23]
%IIs replaced by the hour (12-hour clock) as a decimal number [01, 12]
%jIs replaced by the day of the year as a decimal number [001, 366]
%mIs replaced by the month as a decimal number [01, 12]
%MIs replaced by the minute as a decimal number [00, 59]
%nIs replaced by a newline character
%pIs replaced by the locale equivalent of either a.m. or p.m.
%rIs replaced by the time in a.m./p.m. notation according to British/US conventions (%I:%M:%S\ [AM|PM])
%SIs replaced by the second as a decimal number [00, 61]
%tIs replaced by a tab character
%TIs replaced by the time (%H:%M:%S)
%UIs replaced by the week number of the year (Sunday as the first day of the week) as a decimal number [00, 53]
%wIs replaced by the weekday as a decimal number [0(Sunday), 6]
%WIs replaced by the week number of the year (Monday as the first day of the week) as a decimal number [00, 53]
%xIs replaced by the date representation appropriate for the locale
%XIs replaced by the time representation appropriate for the locale
%yIs replaced by the year without century as a decimal number [00, 99]
%YIs replaced by the year with century as a decimal number
%ZIs replaced by the time zone name or abbreviation, or by no characters when no time zone exists
%%Is replaced by %
When a directive is not one of the above, the behavior of this function is undefined.
NOTES
AES Support Level:
Full use
RETURN VALUES
When the total number of resulting characters, including the terminating null character, is not more than maxsize, the strftime() function returns the number of characters written into the array pointed to by the s parameter. The returned value does not include the terminating null character. Otherwise, a value of (size_t) 0 (zero) is returned and the contents of the array are undefined.
RELATED INFORMATION
Functions: ctime(3), setlocale(3)