1
0
Files
irix-657m-src/eoe/man/man3c/strftime.3c
2022-09-29 17:59:04 +03:00

211 lines
5.5 KiB
Plaintext

'\"macro stdmacro
.if n .pH g3c.strftime @(#)strftime 41.4 of 5/26/91
.\" Copyright 1991 UNIX System Laboratories, Inc.
.\" Copyright 1989, 1990 AT&T
.nr X
.if \nX=0 .ds x} strftime 3C "C Development Set" "\&"
.if \nX=1 .ds x} strftime 3C "C Development Set"
.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"%KC"\fP,
for \f4cftime\fP and \f4ascftime\fP the default format is the same as
\f4"%KC"\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
century number (the year divided by 100 and truncated to an integer) as a decimal number [00-99]
.TP
\f4%d\^\f1
day of month ( 01 - 31 )
.TP
\f4%D\^\f1
date as \f4%m/%d/%y\f1
.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%KC\^\f1
locale's appropriate date and time representation
.TP
\f4%m\^\f1
month number ( 01 - 12 )
.TP
\f4%M\^\f1
minute ( 00 - 59 )
.TP
\f4%n\^\f1
same as new-line
.TP
\f4%p\^\f1
locale's equivalent of either AM or PM
.TP
\f4%r\^\f1
locale's 12-hour time representation, default \f4%I:%M:%S\f1 [\f4AM\f1|\f4PM\f1]
.TP
\f4%R\^\f1
time as \f4%H:%M\f1
.TP
\f4%S\^\f1
seconds ( 00 - 61 ), allows for leap seconds
.TP
\f4%t\^\f1
same as a tab
.TP
\f4%T\^\f1
time as \f4%H:%M:%S\f1
.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
\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.
(If more than \f2maxsize\f1 characters would have been placed into the array,
\f4strftime\f1 returns zero and the array content is indeterminate.
If \f4strftime\fP, \f4cftime\fP, or \f4ascftime\fP
overrun the size of the array, the behavior is undefined.)
.SS Selecting the Output's Language
By default, the output of \f4strftime\fP, \f4cftime\fP, and \f4ascftime\fP
appear in U.S. 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 \f4ctime\fP(3C)
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 \f4"Thursday Aug 28 240"\fP.
.SH FILES
\f4/usr/lib/locale/\f2locale\f4/LC_TIME\f1 \- file
containing locale-specific date and
time information
.SH "SEE ALSO"
\f4time(2)\fP,
\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