check return value from socket call
[unix-history] / usr / src / lib / libc / string / strftime.3
CommitLineData
00b602b8
KB
1.\" Copyright (c) 1989 The Regents of the University of California.
2.\" All rights reserved.
3.\"
4.\" Redistribution and use in source and binary forms are permitted
5.\" provided that the above copyright notice and this paragraph are
6.\" duplicated in all such forms and that any documentation,
7.\" advertising materials, and other materials related to such
8.\" distribution and use acknowledge that the software was developed
9.\" by the University of California, Berkeley. The name of the
10.\" University may not be used to endorse or promote products derived
11.\" from this software without specific prior written permission.
12.\" THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR
13.\" IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
14.\" WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
15.\"
14fd63d8 16.\" @(#)strftime.3 5.4 (Berkeley) %G%
00b602b8
KB
17.\"
18.TH STRFTIME 3 "%Q"
19.AT 3
20.SH NAME
21strftime \- format date and time
22.SH SYNOPSIS
23.nf
24.ft B
25#include <sys/types.h>
26#include <time.h>
27
28size_t
29strftime(char *s, size_t maxsize, const char *format,
30 const struct tm *timeptr);
31.ft R
32.fi
33.SH DESCRIPTION
34The
35.I strftime
36function formats the information from
37.I timeptr
38into the buffer
39.I buf
40according to the string pointed to by
41.IR format .
42.PP
43The
44.I format
45string consists of zero or more conversion specifications and
46ordinary characters.
47All ordinary characters are copied directly into the buffer.
48A conversion specification consists of a percent sign (``%'')
49and one other character.
50.PP
51No more than
52.I maxsize
53characters will be placed into the array.
54If the total number of resulting characters, including the terminating
55null character, is not more than
56.IR maxsize ,
57.I strftime
58returns the number of characters in the array, not counting the
59terminating null.
60Otherwise, zero is returned.
61.PP
62Each conversion specification is replaced by the characters as
63follows which are then copied into the buffer.
64.TP
65.B %A
66is replaced by the full weekday name.
67.TP
68.B %a
69is replaced by the abbreviated weekday name, where the abbreviation
70is the first three characters.
71.TP
72.B %B
73is replaced by the full month name.
74.TP
e386ba1e 75.B %b or %h
00b602b8
KB
76is replaced by the abbreviated month name, where the abbreviation is
77the first three characters.
78.TP
14fd63d8
KB
79.B %C
80is equivalent to ``%a %b %e %H:%M:%S %Y'' (the format produced by
81.IR asctime (3).
82.TP
00b602b8 83.B %c
5a2e4b32 84is equivalent to ``%m/%d/%y''.
00b602b8 85.TP
e386ba1e
KB
86.B %D
87is replaced by the date in the format ``mm/dd/yy''.
88.TP
00b602b8
KB
89.B %d
90is replaced by the day of the month as a decimal number (01-31).
91.TP
14fd63d8
KB
92.B %e
93is replaced by the day of month as a decimal number (1-31); single
94digits are preceded by a blank.
95.TP
00b602b8
KB
96.B %H
97is replaced by the hour (24-hour clock) as a decimal number (00-23).
98.TP
99.B %I
100is replaced by the hour (12-hour clock) as a decimal number (01-12).
101.TP
102.B %j
103is replaced by the day of the year as a decimal number (001-366).
104.TP
14fd63d8
KB
105.B %k
106is replaced by the hour (24-hour clock) as a decimal number (0-23);
107single digits are preceded by a blank.
108.TP
109.B %l
110is replaced by the hour (12-hour clock) as a decimal number (01-12);
111single digits are preceded by a blank.
112.TP
e386ba1e
KB
113.B %M
114is replaced by the minute as a decimal number (00-59).
115.TP
00b602b8
KB
116.B %m
117is replaced by the month as a decimal number (01-12).
118.TP
e386ba1e
KB
119.B %n
120is replaced by a newline.
00b602b8
KB
121.TP
122.B %p
123is replaced by either ``AM'' or ``PM'' as appropriate.
124.TP
e386ba1e
KB
125.B %R
126is equivalent to ``%H:%M''.
127.TP
128.B %r
129is equivalent to ``%I:%M:%S %p''.
130.TP
131.B %t
132is replaced by a tab.
133.TP
00b602b8
KB
134.B %S
135is replaced by the second as a decimal number (00-60).
136.TP
e386ba1e
KB
137.B %T or %X
138is equivalent to ``%H:%M:%S''.
139.TP
00b602b8
KB
140.B %U
141is replaced by the week number of the year (Sunday as the first day of
142the week) as a decimal number (00-53).
143.TP
144.B %W
145is replaced by the week number of the year (Monday as the first day of
146the week) as a decimal number (00-53).
147.TP
148.B %w
149is replaced by the weekday (Sunday as the first day of the week)
150as a decimal number (0-6).
151.TP
00b602b8 152.B %x
5a2e4b32 153is equivalent to ``%m/%d/%y %H:%M:%S''.
00b602b8
KB
154.TP
155.B %Y
156is replaced by the year with century as a decimal number.
157.TP
158.B %y
159is replaced by the year without century as a decimal number (00-99).
160.TP
161.B %Z
162is replaced by the time zone name.
163.TP
164.B %%
165is replaced by ``%''.
166.SH "SEE ALSO"
14fd63d8 167date(1), ctime(3), printf(1), printf(3)