File: strftime.3

package info (click to toggle)
manpages 1.19-1
  • links: PTS
  • area: main
  • in suites: hamm
  • size: 3,668 kB
  • ctags: 4
  • sloc: sh: 87; makefile: 53
file content (186 lines) | stat: -rw-r--r-- 5,723 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
.\" Copyright 1993 David Metcalfe (david@prism.demon.co.uk)
.\"
.\" Permission is granted to make and distribute verbatim copies of this
.\" manual provided the copyright notice and this permission notice are
.\" preserved on all copies.
.\"
.\" Permission is granted to copy and distribute modified versions of this
.\" manual under the conditions for verbatim copying, provided that the
.\" entire resulting derived work is distributed under the terms of a
.\" permission notice identical to this one
.\" 
.\" Since the Linux kernel and libraries are constantly changing, this
.\" manual page may be incorrect or out-of-date.  The author(s) assume no
.\" responsibility for errors or omissions, or for damages resulting from
.\" the use of the information contained herein.  The author(s) may not
.\" have taken the same level of care in the production of this manual,
.\" which is licensed free of charge, as they might when working
.\" professionally.
.\" 
.\" Formatted or processed versions of this manual, if unaccompanied by
.\" the source, must acknowledge the copyright and authors of this work.
.\"
.\" References consulted:
.\"     Linux libc source code
.\"     Lewine's _POSIX Programmer's Guide_ (O'Reilly & Associates, 1991)
.\"     386BSD man pages
.\" Modified Sat Jul 24 18:03:44 1993 by Rik Faith (faith@cs.unc.edu)
.\" Applied fix by Wolfgang Franke, aeb, 961011
.\" Corrected return value, aeb, 970307
.TH STRFTIME 3  "July 2, 1993" "GNU" "Linux Programmer's Manual"
.SH NAME
strftime \- format date and time
.SH SYNOPSIS
.nf
.B #include <time.h>
.sp
.BI "size_t strftime(char *" s ", size_t " max ", const char *" format ,
.BI "				const struct tm *" tm );
.fi
.SH DESCRIPTION
The \fBstrftime()\fP function formats the broken-down time \fItm\fP
according to the format specification \fIformat\fP and places the
result in the character array \fIs\fP of size \fImax\fP.
.PP
Ordinary characters placed in the format string are copied to \fIs\fP
without conversion.  Conversion specifiers are introduced by a `%'
character, and are replaced in \fIs\fP as follows:
.TP
.B %a
The abbreviated weekday name according to the current locale.
.TP
.B %A
The full weekday name according to the current locale.
.TP
.B %b
The abbreviated month name according to the current locale.
.TP
.B %B
The full month name according to the current locale.
.TP
.B %c
The preferred date and time representation for the current locale.
.TP
.B %d
The day of the month as a decimal number (range 01 to 31).
.TP
.B %H
The hour as a decimal number using a 24-hour clock (range 00 to 23).
.TP
.B %I
The hour as a decimal number using a 12-hour clock (range 01 to 12).
.TP
.B %j
The day of the year as a decimal number (range 001 to 366).
.TP
.B %m
The month as a decimal number (range 01 to 12).
.TP
.B %M
The minute as a decimal number.
.TP
.B %p
Either `am' or `pm' according to the given time value, or the 
corresponding strings for the current locale.
.TP
.B %S
The second as a decimal number.
.TP
.B %U
The week number of the current year as a decimal number, starting
with the first Sunday as the first day of the first week.
.TP
.B %W
The week number of the current year as a decimal number, starting
with the first Monday as the first day of the first week.
.TP
.B %w
The day of the week as a decimal, Sunday being 0.
.TP
.B %x
The preferred date representation for the current locale without the time.
.TP
.B %X
The preferred time representation for the current locale without the date.
.TP
.B %y
The year as a decimal number without a century (range 00 to 99).
.TP
.B %Y
The year as a decimal number including the century.
.TP
.B %Z
The time zone or name or abbreviation.
.TP
.B %%
A literal `%' character.
.PP
The broken-down time structure \fItm\fP is defined in \fI<time.h>\fP
as follows:
.sp
.RS
.nf
.ne 12
.ta 8n 16n 32n
struct tm
{
	int	tm_sec;			/* seconds */
	int	tm_min;			/* minutes */
	int	tm_hour;		/* hours */
	int	tm_mday;		/* day of the month */
	int	tm_mon;			/* month */
	int	tm_year;		/* year */
	int	tm_wday;		/* day of the week */
	int	tm_yday;		/* day in the year */
	int	tm_isdst;		/* daylight saving time */
};
.ta
.fi
.RE
.PP
The members of the \fItm\fP structure are:
.TP
.I tm_sec
The number of seconds after the minute, normally in the range 0 to 59, 
but can be up to 61 to allow for leap seconds.
.TP
.I tm_min
The number of minutes after the hour, in the range 0 to 59. 
.TP
.I tm_hour
The number of hours past midnight, in the range 0 to 23.
.TP
.I tm_mday
The day of the month, in the range 1 to 31.
.TP
.I tm_mon
The number of months since January, in the range 0 to 11.
.TP
.I tm_year
The number of years since 1900.
.TP
.I tm_wday
The number of days since Sunday, in the range 0 to 6.
.TP
.I tm_yday
The number of days since January 1, in the range 0 to 365.
.TP
.I tm_isdst
A flag that indicates whether daylight saving time is in effect at the
time described.  The value is positive if daylight saving time is in
effect, zero if it is not, and negative if the information is not
available.
.SH "RETURN VALUE"
The \fBstrftime()\fP function returns the number of characters placed
in the array \fIs\fP, not including the terminating NULL character,
provided the string, including the terminating NULL, fits.
Otherwise, it returns 0, and the contents of the array is undefined.
(Thus at least since libc 4.4.4; very old versions of libc,
such as libc 4.4.1, would return \fImax\fP if the array was too small.)
.LP
Note that the return value 0 does not necessarily indicate an error;
for example, in many locales %p yields an empty string.
.SH "CONFORMING TO"
ANSI C, SVID 3, POSIX, BSD 4.3, ISO 9899
.SH "SEE ALSO"
.BR date "(1), " time "(2), " ctime "(3), " setlocale "(3), " sprintf (3)