BSD 4_4 release
[unix-history] / usr / src / lib / libc / string / strftime.3
index da45d1a..3da35a1 100644 (file)
-.\" Copyright (c) 1989 The Regents of the University of California.
-.\" All rights reserved.
+.\" Copyright (c) 1989, 1991, 1993
+.\"    The Regents of the University of California.  All rights reserved.
 .\"
 .\"
-.\" Redistribution and use in source and binary forms are permitted provided
-.\" that: (1) source distributions retain this entire copyright notice and
-.\" comment, and (2) distributions including binaries display the following
-.\" acknowledgement:  ``This product includes software developed by the
-.\" University of California, Berkeley and its contributors'' in the
-.\" documentation or other materials provided with the distribution and in
-.\" all advertising materials mentioning features or use of this software.
-.\" Neither the name of the University nor the names of its contributors may
-.\" be used to endorse or promote products derived from this software without
-.\" specific prior written permission.
-.\" THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR IMPLIED
-.\" WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF
-.\" MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
+.\" This code is derived from software contributed to Berkeley by
+.\" the American National Standards Committee X3, on Information
+.\" Processing Systems.
 .\"
 .\"
-.\"    @(#)strftime.3  5.6 (Berkeley) 6/23/90
+.\" Redistribution and use in source and binary forms, with or without
+.\" modification, are permitted provided that the following conditions
+.\" are met:
+.\" 1. Redistributions of source code must retain the above copyright
+.\"    notice, this list of conditions and the following disclaimer.
+.\" 2. Redistributions in binary form must reproduce the above copyright
+.\"    notice, this list of conditions and the following disclaimer in the
+.\"    documentation and/or other materials provided with the distribution.
+.\" 3. All advertising materials mentioning features or use of this software
+.\"    must display the following acknowledgement:
+.\"    This product includes software developed by the University of
+.\"    California, Berkeley and its contributors.
+.\" 4. Neither the name of the University nor the names of its contributors
+.\"    may be used to endorse or promote products derived from this software
+.\"    without specific prior written permission.
 .\"
 .\"
-.TH STRFTIME 3 "%Q"
-.AT 3
-.SH NAME
-strftime \- format date and time
-.SH SYNOPSIS
-.nf
-.ft B
-#include <sys/types.h>
-#include <time.h>
-#include <string.h>
-
-size_t
-strftime(char *s, size_t maxsize, const char *format,
-       const struct tm *timeptr);
-.ft R
-.fi
-.SH DESCRIPTION
+.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
+.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+.\" ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
+.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+.\" SUCH DAMAGE.
+.\"
+.\"     @(#)strftime.3 8.1 (Berkeley) 6/4/93
+.\"
+.Dd June 4, 1993
+.Dt STRFTIME 3
+.Os
+.Sh NAME
+.Nm strftime
+.Nd format date and time
+.Sh SYNOPSIS
+.Fd #include <sys/types.h>
+.Fd #include <time.h>
+.Fd #include <string.h>
+.Ft size_t
+.Fn strftime "char *buf" "size_t maxsize" "const char *format" "const struct tm *timeptr"
+.Sh DESCRIPTION
 The
 The
-.I strftime
+.Fn strftime
 function formats the information from
 function formats the information from
-.I timeptr
+.Fa timeptr
 into the buffer
 into the buffer
-.I buf
+.Fa buf
 according to the string pointed to by
 according to the string pointed to by
-.IR format .
-.PP
+.Fa format .
+.Pp
 The
 The
-.I format
+.Fa format
 string consists of zero or more conversion specifications and
 ordinary characters.
 All ordinary characters are copied directly into the buffer.
 string consists of zero or more conversion specifications and
 ordinary characters.
 All ordinary characters are copied directly into the buffer.
-A conversion specification consists of a percent sign (``%'')
+A conversion specification consists of a percent sign
+.Dq Ql %
 and one other character.
 and one other character.
-.PP
+.Pp
 No more than
 No more than
-.I maxsize
+.Fa maxsize
 characters will be placed into the array.
 If the total number of resulting characters, including the terminating
 null character, is not more than
 characters will be placed into the array.
 If the total number of resulting characters, including the terminating
 null character, is not more than
-.IR maxsize ,
-.I strftime
+.Fa maxsize ,
+.Fn strftime
 returns the number of characters in the array, not counting the
 terminating null.
 Otherwise, zero is returned.
 returns the number of characters in the array, not counting the
 terminating null.
 Otherwise, zero is returned.
-.PP
+.Pp
 Each conversion specification is replaced by the characters as
 follows which are then copied into the buffer.
 Each conversion specification is replaced by the characters as
 follows which are then copied into the buffer.
-.TP
-.%A
+.Bl -tag -width "xxxx"
+.It Cm \&%A
 is replaced by the full weekday name.
 is replaced by the full weekday name.
-.TP
-.B %a
+.It Cm %a
 is replaced by the abbreviated weekday name, where the abbreviation
 is the first three characters.
 is replaced by the abbreviated weekday name, where the abbreviation
 is the first three characters.
-.TP
-.B %B
+.It Cm \&%B
 is replaced by the full month name.
 is replaced by the full month name.
-.TP
-.B %b or %h
+.It Cm %b  or  %h
 is replaced by the abbreviated month name, where the abbreviation is
 the first three characters.
 is replaced by the abbreviated month name, where the abbreviation is
 the first three characters.
-.TP
-.B %C
-is equivalent to ``%a %b %e %H:%M:%S %Y'' (the format produced by
-.IR asctime (3).
-.TP
-.B %c
-is equivalent to ``%m/%d/%y''.
-.TP
-.%D
-is replaced by the date in the format ``mm/dd/yy''.
-.TP
-.B %d
+.It Cm \&%C
+is equivalent to
+.Dq Li %a %b %e %H:%M:%S %Y
+(the format produced by
+.Xr asctime 3 .
+.It Cm %c
+is equivalent to
+.Dq Li %m/%d/%y .
+.It Cm \&%D
+is replaced by the date in the format
+.Dq Ql mm/dd/yy .
+.It Cm %d
 is replaced by the day of the month as a decimal number (01-31).
 is replaced by the day of the month as a decimal number (01-31).
-.TP
-.B %e
+.It Cm %e
 is replaced by the day of month as a decimal number (1-31); single
 digits are preceded by a blank.
 is replaced by the day of month as a decimal number (1-31); single
 digits are preceded by a blank.
-.TP
-.B %H
+.It Cm \&%H
 is replaced by the hour (24-hour clock) as a decimal number (00-23).
 is replaced by the hour (24-hour clock) as a decimal number (00-23).
-.TP
-.B %I
+.It Cm \&%I
 is replaced by the hour (12-hour clock) as a decimal number (01-12).
 is replaced by the hour (12-hour clock) as a decimal number (01-12).
-.TP
-.B %j
+.It Cm %j
 is replaced by the day of the year as a decimal number (001-366).
 is replaced by the day of the year as a decimal number (001-366).
-.TP
-.B %k
+.It Cm %k
 is replaced by the hour (24-hour clock) as a decimal number (0-23);
 single digits are preceded by a blank.
 is replaced by the hour (24-hour clock) as a decimal number (0-23);
 single digits are preceded by a blank.
-.TP
-.B %l
-is replaced by the hour (12-hour clock) as a decimal number (01-12);
+.It Cm %l
+is replaced by the hour (12-hour clock) as a decimal number (1-12);
 single digits are preceded by a blank.
 single digits are preceded by a blank.
-.TP
-.B %M
+.It Cm \&%M
 is replaced by the minute as a decimal number (00-59).
 is replaced by the minute as a decimal number (00-59).
-.TP
-.B %m
+.It Cm %m
 is replaced by the month as a decimal number (01-12).
 is replaced by the month as a decimal number (01-12).
-.TP
-.B %n
+.It Cm %n
 is replaced by a newline.
 is replaced by a newline.
-.TP
-.B %p
-is replaced by either ``AM'' or ``PM'' as appropriate.
-.TP
-.B %R
-is equivalent to ``%H:%M''.
-.TP
-.B %r
-is equivalent to ``%I:%M:%S %p''.
-.TP
-.B %t
+.It Cm %p
+is replaced by either
+.Dq Tn AM
+or
+.Dq Tn PM
+as appropriate.
+.It Cm \&%R
+is equivalent to
+.Dq Li %H:%M
+.It Cm %r
+is equivalent to
+.Dq Li %I:%M:%S %p .
+.It Cm %t
 is replaced by a tab.
 is replaced by a tab.
-.TP
-.B %S
+.It Cm \&%S
 is replaced by the second as a decimal number (00-60).
 is replaced by the second as a decimal number (00-60).
-.TP
-.B %T or %X
-is equivalent to ``%H:%M:%S''.
-.TP
-.B %U
+.It Cm %s
+is replaced by the number of seconds since the Epoch, UCT (see
+.Xr mktime 3 ) .
+.It Cm \&%T No or Cm \&%X
+is equivalent to
+.Dq Li %H:%M:%S .
+.It Cm \&%U
 is replaced by the week number of the year (Sunday as the first day of
 the week) as a decimal number (00-53).
 is replaced by the week number of the year (Sunday as the first day of
 the week) as a decimal number (00-53).
-.TP
-.B %W
+.It Cm \&%W
 is replaced by the week number of the year (Monday as the first day of
 the week) as a decimal number (00-53).
 is replaced by the week number of the year (Monday as the first day of
 the week) as a decimal number (00-53).
-.TP
-.B %w
+.It Cm %w
 is replaced by the weekday (Sunday as the first day of the week)
 as a decimal number (0-6).
 is replaced by the weekday (Sunday as the first day of the week)
 as a decimal number (0-6).
-.TP
-.B %x
-is equivalent to ``%m/%d/%y %H:%M:%S''.
-.TP
-.B %Y
+.It Cm %x
+is equivalent to
+.Dq Li %m/%d/%y %H:%M:%S .
+.It Cm \&%Y
 is replaced by the year with century as a decimal number.
 is replaced by the year with century as a decimal number.
-.TP
-.B %y
+.It Cm %y
 is replaced by the year without century as a decimal number (00-99).
 is replaced by the year without century as a decimal number (00-99).
-.TP
-.B %Z
+.It Cm \&%Z
 is replaced by the time zone name.
 is replaced by the time zone name.
-.TP
-.B %%
-is replaced by ``%''.
-.SH "SEE ALSO"
-date(1), ctime(3), printf(1), printf(3)
-.SH STANDARDS
-.B Strftime
-conforms to ANSI X3.159-1989 (``ANSI C'').
+.It Cm %%
+is replaced by
+.Ql % .
+.El
+.Sh SEE ALSO
+.Xr date 1 ,
+.Xr ctime 3 ,
+.Xr printf 1 ,
+.Xr printf 3
+.Sh STANDARDS
+The
+.Fn strftime
+function
+conforms to
+.St -ansiC .
+The
+.Ql %s
+conversion specification is an extension.
+.Sh BUGS
+There is no conversion specification for the phase of the moon.