'\"macro stdmacro
.if n .pH g3c.strftime @(#)strftime	40.16 of 10/27/89
.\" Copyright 1989 AT&T
.nr X
.if \nX=0 .ds x} strftime 3C "C Programming Language Utilities" "\&"
.if \nX=1 .ds x} strftime 3C "C Programming Language Utilities"
.if \nX=2 .ds x} strftime 3C "" "\&"
.if \nX=3 .ds x} strftime "" "" "\&"
.TH \*(x}
.SH NAME
\f4strftime\f1, \f4cftime\f1, \f4ascftime\f1 - convert date and time to string
.SH SYNOPSIS
\f4#include <time.h>\f1
.PP
.nf
\f4size_t \(**strftime (char \(**s, size_t maxsize, \f4const char \(**format,
    const struct tm \(**timeptr);\f1
.PP
\f4int cftime (char \(**s, char *format, const time_t *clock);\f1
.PP
\f4int ascftime (char \(**s, const char *format, const struct tm 
    *timeptr);\f1
.fi
.SH DESCRIPTION
\f4strftime\fP, \f4ascftime\fP, and \f4cftime\fP
place characters into the array pointed to by 
\f4s\f1 as controlled by the string pointed to by \f2format\f1.
The \f2format\f1
string consists of zero or more directives and ordinary characters.
All ordinary characters (including the terminating null character) are copied
unchanged into the array.
For \f4strftime\fP, no more than \f2maxsize\f1 characters are placed into the array.
.PP
If 
\f2format\f1
is (char \(**)0, 
then the locale's default format is used.
For \f4strftime\fP the default format is the same as \f4"%c"\fP,
for \f4cftime\fP and \f4ascftime\fP the default format is the same as
\f4"%C"\fP.
\f4cftime\fP and \f4ascftime\fP first try to use the value of the environment
variable \f4CFTIME\fP, and if that is undefined or empty, the default format
is used.
.PP
Each directive is replaced by appropriate characters
as described in the following list.
The appropriate characters are determined by 
the \f4LC_TIME\fP category of the program's locale and by the values 
contained in the structure pointed to 
by \f2timeptr\f1 for \f4strftime\fP and \f4ascftime\fP, and by the time
represented by \f2clock\fP for \f4cftime\fP.
.TP 10n
.PD 0
\f4%%\^\f1
same as %
.TP
\f4%a\^\f1
locale's abbreviated weekday name
.TP
\f4%A\^\f1
locale's full weekday name
.TP
\f4%b\^\f1
locale's abbreviated month name
.TP
\f4%B\^\f1
locale's full month name
.TP
\f4%c\^\f1
locale's appropriate date and time representation
.TP
\f4%C\^\f1
locale's date and time representation as produced by \f4date\fP(1)
.TP
\f4%d\^\f1
day of month ( 01 - 31 )
.TP
\f4%D\^\f1
date as %m/%d/%y
.TP
\f4%e\^\f1
day of month (1-31; single digits are preceded by a blank)
.TP
\f4%h\^\f1
locale's abbreviated month name.
.TP
\f4%H\^\f1
hour ( 00 - 23 )
.TP
\f4%I\^\f1
hour ( 01 - 12 )
.TP
\f4%j\^\f1
day number of year ( 001 - 366 )
.TP
\f4%m\^\f1
month number ( 01 - 12 )
.TP
\f4%M\^\f1
minute ( 00 - 59 )
.TP
\f4%n\^\f1
same as \\n
.TP
\f4%p\^\f1
locale's equivalent of either AM or PM
.TP
\f4%r\^\f1
time as %I:%M:%S [AM|PM]
.TP
\f4%R\^\f1
time as %H:%M
.TP
\f4%S\^\f1
seconds ( 00 - 61 ), allows for leap seconds
.TP
\f4%t\^\f1
insert a tab
.TP
\f4%T\^\f1
time as %H:%M:%S
.TP
\f4%U\^\f1
week number of year ( 00 - 53 ),
Sunday is the first day of week 1
.TP
\f4%w\^\f1
weekday number ( 0 - 6 ), Sunday = 0
.TP
\f4%W\^\f1
week number of year ( 00 - 53 ),
Monday is the first day of week 1
.TP
\f4%x\^\f1
locale's appropriate date representation
.TP
\f4%X\^\f1
locale's appropriate time representation
.TP
\f4%y\^\f1
year within century ( 00 - 99 )
.TP
\f4%Y\^\f1
year as ccyy ( e.g. 1986)
.TP
\f4%Z\^\f1
time zone name or no characters if no time zone exists
.PD
.PP
The difference between \f4%U\f1 and \f4%W\f1 lies in which day
is counted as the first of the week.
Week number 01 is
the first week in January starting with a 
Sunday for \f4%U\f1 or a Monday for \f4%W\f1.
Week number 00 contains
those days before the first Sunday or Monday in January for \f4%U\f1 and \f4%W\f1,
respectively.
.PP
If the total number of resulting characters including the terminating null
character is not more than \f2maxsize\f1,
\f4strftime\fP, \f4cftime\fP and \f4ascftime\fP return the number of
characters placed into the array pointed to by \f2s\f1 not including the
terminating null character.
Otherwise, zero is returned and the contents of the 
array are indeterminate.
\f4cftime\f1 and
\f4ascftime\f1 return the number
of characters placed into the array
pointed to by \f2s\f1
not including the terminating null character.
.SS Selecting the Output's Language
By default, the output of \f4strftime\fP, \f4cftime\fP, and \f4ascftime\fP
appear in US English.
The user can request that the output of \f4strftime\fP,
\f4cftime\fP or \f4ascftime\fP
be in a specific language by
setting the \f2locale\f1 for \f2category\f1
\f4LC_TIME\fP
in \f4setlocale\fP.
.PP
.SS Timezone 
The timezone is taken from the environment variable
\f4TZ\f1 [see \f1ctime(3C)\f1
for a description of
\f4TZ\f1].
.SH EXAMPLES 
.PP
The example illustrates the use of \f4strftime\fP.  It
shows what the string in \f4str\fP would look
like if the structure pointed to by \f2tmptr\f1
contains the values corresponding to Thursday, August 28, 1986 at 12:44:36 in
New Jersey.
.sp .5
.RS
	\f4strftime (str, strsize, "%A %b %d %j", tmptr)\f1
.RE
.sp .5
This results in \f4str\fP containing "Thursday Aug 28 240".
.SH FILES
\f4/usr/lib/locale/\f2language\f4/LC_TIME\f1 \- file
containing locale specific date and
time information
.SH "SEE ALSO"
\f4ctime\fP(3C), \f4getenv\fP(3C), \f4setlocale\fP(3C),
\f4strftime\f1(4), \f4timezone\fP(4), \f4environ\fP(5).
.SH "NOTE"
\f4cftime\fP and \f4ascftime\fP are obsolete.
\f4strftime\fP should be used instead.
.\"	@(#)strftime.3c	
.Ee
