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
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
|
.\" Copyright (c) 2001-2003 The Open Group, All Rights Reserved
.TH "STRPTIME" P 2003 "IEEE/The Open Group" "POSIX Programmer's Manual"
.\" strptime
.SH NAME
strptime \- date and time conversion
.SH SYNOPSIS
.LP
\fB#include <time.h>
.br
.sp
char *strptime(const char *restrict\fP \fIbuf\fP\fB, const char *restrict\fP
\fIformat\fP\fB,
.br
\ \ \ \ \ \ struct tm *restrict\fP \fItm\fP\fB); \fP
\fB
.br
\fP
.SH DESCRIPTION
.LP
The \fIstrptime\fP() function shall convert the character string pointed
to by \fIbuf\fP to values which are stored in the
\fBtm\fP structure pointed to by \fItm\fP, using the format specified
by \fIformat\fP.
.LP
The \fIformat\fP is composed of zero or more directives. Each directive
is composed of one of the following: one or more
white-space characters (as specified by \fIisspace\fP()); an ordinary
character (neither
\fB'%'\fP nor a white-space character); or a conversion specification.
Each conversion specification is composed of a
\fB'%'\fP character followed by a conversion character which specifies
the replacement required. The application shall ensure
that there is white-space or other non-alphanumeric characters between
any two conversion specifications. The following conversion
specifications are supported:
.TP 7
\fB%a\fP
The day of the week, using the locale's weekday names; either the
abbreviated or full name may be specified.
.TP 7
\fB%A\fP
Equivalent to \fB%a\fP .
.TP 7
\fB%b\fP
The month, using the locale's month names; either the abbreviated
or full name may be specified.
.TP 7
\fB%B\fP
Equivalent to \fB%b\fP .
.TP 7
\fB%c\fP
Replaced by the locale's appropriate date and time representation.
.TP 7
\fB%C\fP
The century number [00,99]; leading zeros are permitted but not required.
.TP 7
\fB%d\fP
The day of the month [01,31]; leading zeros are permitted but not
required.
.TP 7
\fB%D\fP
The date as \fB%m\fP / \fB%d\fP / \fB%y\fP .
.TP 7
\fB%e\fP
Equivalent to \fB%d\fP .
.TP 7
\fB%h\fP
Equivalent to \fB%b\fP .
.TP 7
\fB%H\fP
The hour (24-hour clock) [00,23]; leading zeros are permitted but
not required.
.TP 7
\fB%I\fP
The hour (12-hour clock) [01,12]; leading zeros are permitted but
not required.
.TP 7
\fB%j\fP
The day number of the year [001,366]; leading zeros are permitted
but not required.
.TP 7
\fB%m\fP
The month number [01,12]; leading zeros are permitted but not required.
.TP 7
\fB%M\fP
The minute [00,59]; leading zeros are permitted but not required.
.TP 7
\fB%n\fP
Any white space.
.TP 7
\fB%p\fP
The locale's equivalent of a.m or p.m.
.TP 7
\fB%r\fP
12-hour clock time using the AM/PM notation if \fBt_fmt_ampm\fP is
not an empty string in the LC_TIME portion of the current
locale; in the POSIX locale, this shall be equivalent to \fB%I\fP
: \fB%M\fP : \fB%S\fP \fB%p\fP .
.TP 7
\fB%R\fP
The time as \fB%H\fP : \fB%M\fP .
.TP 7
\fB%S\fP
The seconds [00,60]; leading zeros are permitted but not required.
.TP 7
\fB%t\fP
Any white space.
.TP 7
\fB%T\fP
The time as \fB%H\fP : \fB%M\fP : \fB%S\fP .
.TP 7
\fB%U\fP
The week number of the year (Sunday as the first day of the week)
as a decimal number [00,53]; leading zeros are permitted but
not required.
.TP 7
\fB%w\fP
The weekday as a decimal number [0,6], with 0 representing Sunday;
leading zeros are permitted but not required.
.TP 7
\fB%W\fP
The week number of the year (Monday as the first day of the week)
as a decimal number [00,53]; leading zeros are permitted but
not required.
.TP 7
\fB%x\fP
The date, using the locale's date format.
.TP 7
\fB%X\fP
The time, using the locale's time format.
.TP 7
\fB%y\fP
The year within century. When a century is not otherwise specified,
values in the range [69,99] shall refer to years 1969 to
1999 inclusive, and values in the range [00,68] shall refer to years
2000 to 2068 inclusive; leading zeros shall be permitted but
shall not be required.
.TP 7
\fBNote:\fP
.RS
It is expected that in a future version of IEEE\ Std\ 1003.1-2001
the default century inferred from a 2-digit year will
change. (This would apply to all commands accepting a 2-digit year
as input.)
.RE
.sp
.TP 7
\fB%Y\fP
The year, including the century (for example, 1988).
.TP 7
\fB%%\fP
Replaced by \fB%\fP .
.sp
.SS Modified Conversion Specifiers
.LP
Some conversion specifiers can be modified by the \fBE\fP and \fBO\fP
modifier characters to indicate that an alternative
format or specification should be used rather than the one normally
used by the unmodified conversion specifier. If the alternative
format or specification does not exist in the current locale, the
behavior shall be as if the unmodified conversion specification
were used.
.TP 7
\fB%Ec\fP
The locale's alternative appropriate date and time representation.
.TP 7
\fB%EC\fP
The name of the base year (period) in the locale's alternative representation.
.TP 7
\fB%Ex\fP
The locale's alternative date representation.
.TP 7
\fB%EX\fP
The locale's alternative time representation.
.TP 7
\fB%Ey\fP
The offset from \fB%EC\fP (year only) in the locale's alternative
representation.
.TP 7
\fB%EY\fP
The full alternative year representation.
.TP 7
\fB%Od\fP
The day of the month using the locale's alternative numeric symbols;
leading zeros are permitted but not required.
.TP 7
\fB%Oe\fP
Equivalent to \fB%Od\fP .
.TP 7
\fB%OH\fP
The hour (24-hour clock) using the locale's alternative numeric symbols.
.TP 7
\fB%OI\fP
The hour (12-hour clock) using the locale's alternative numeric symbols.
.TP 7
\fB%Om\fP
The month using the locale's alternative numeric symbols.
.TP 7
\fB%OM\fP
The minutes using the locale's alternative numeric symbols.
.TP 7
\fB%OS\fP
The seconds using the locale's alternative numeric symbols.
.TP 7
\fB%OU\fP
The week number of the year (Sunday as the first day of the week)
using the locale's alternative numeric symbols.
.TP 7
\fB%Ow\fP
The number of the weekday (Sunday=0) using the locale's alternative
numeric symbols.
.TP 7
\fB%OW\fP
The week number of the year (Monday as the first day of the week)
using the locale's alternative numeric symbols.
.TP 7
\fB%Oy\fP
The year (offset from \fB%C\fP ) using the locale's alternative numeric
symbols.
.sp
.LP
A conversion specification composed of white-space characters is executed
by scanning input up to the first character that is
not white-space (which remains unscanned), or until no more characters
can be scanned.
.LP
A conversion specification that is an ordinary character is executed
by scanning the next character from the buffer. If the
character scanned from the buffer differs from the one comprising
the directive, the directive fails, and the differing and
subsequent characters remain unscanned.
.LP
A series of conversion specifications composed of \fB%n\fP , \fB%t\fP
, white-space characters, or any combination is
executed by scanning up to the first character that is not white space
(which remains unscanned), or until no more characters can
be scanned.
.LP
Any other conversion specification is executed by scanning characters
until a character matching the next directive is scanned,
or until no more characters can be scanned. These characters, except
the one matching the next directive, are then compared to the
locale values associated with the conversion specifier. If a match
is found, values for the appropriate \fBtm\fP structure members
are set to values corresponding to the locale information. Case is
ignored when matching items in \fIbuf\fP such as month or
weekday names. If no match is found, \fIstrptime\fP() fails and no
more characters are scanned.
.SH RETURN VALUE
.LP
Upon successful completion, \fIstrptime\fP() shall return a pointer
to the character following the last character parsed.
Otherwise, a null pointer shall be returned.
.SH ERRORS
.LP
No errors are defined.
.LP
\fIThe following sections are informative.\fP
.SH EXAMPLES
.LP
None.
.SH APPLICATION USAGE
.LP
Several "equivalent to" formats and the special processing of white-space
characters are provided in order to ease the use of
identical \fIformat\fP strings for \fIstrftime\fP() and \fIstrptime\fP().
.LP
Applications should use \fB%Y\fP (4-digit years) in preference to
\fB%y\fP (2-digit years).
.LP
It is unspecified whether multiple calls to \fIstrptime\fP() using
the same \fBtm\fP structure will update the current
contents of the structure or overwrite all contents of the structure.
Conforming applications should make a single call to
\fIstrptime\fP() with a format and all data needed to completely specify
the date and time being converted.
.SH RATIONALE
.LP
None.
.SH FUTURE DIRECTIONS
.LP
The \fIstrptime\fP() function is expected to be mandatory in the next
version of this volume of
IEEE\ Std\ 1003.1-2001.
.SH SEE ALSO
.LP
\fIscanf\fP() , \fIstrftime\fP() , \fItime\fP()
, the Base Definitions volume of IEEE\ Std\ 1003.1-2001, \fI<time.h>\fP
.SH COPYRIGHT
Portions of this text are reprinted and reproduced in electronic form
from IEEE Std 1003.1, 2003 Edition, Standard for Information Technology
-- Portable Operating System Interface (POSIX), The Open Group Base
Specifications Issue 6, Copyright (C) 2001-2003 by the Institute of
Electrical and Electronics Engineers, Inc and The Open Group. In the
event of any discrepancy between this version and the original IEEE and
The Open Group Standard, the original IEEE and The Open Group Standard
is the referee document. The original Standard can be obtained online at
http://www.opengroup.org/unix/online.html .
|