version 1, including all changes.
.
Rev |
Author |
# |
Line |
1 |
perry |
1 |
STRPTIME |
|
|
2 |
!!!STRPTIME |
|
|
3 |
NAME |
|
|
4 |
SYNOPSIS |
|
|
5 |
DESCRIPTION |
|
|
6 |
RETURN VALUE |
|
|
7 |
NOTES |
|
|
8 |
SEE ALSO |
|
|
9 |
---- |
|
|
10 |
!!NAME |
|
|
11 |
|
|
|
12 |
|
|
|
13 |
strptime - convert a string representation of time to a time tm structure |
|
|
14 |
!!SYNOPSIS |
|
|
15 |
|
|
|
16 |
|
|
|
17 |
__#define _XOPEN_SOURCE__ /* glibc2 needs this */__ |
|
|
18 |
#include |
|
|
19 |
|
|
|
20 |
|
|
|
21 |
__char *strptime(const char *__''s''__, const char |
|
|
22 |
*__''format''__, struct tm |
|
|
23 |
*__''tm''__);__ |
|
|
24 |
!!DESCRIPTION |
|
|
25 |
|
|
|
26 |
|
|
|
27 |
__strptime()__ is the complementary function to |
|
|
28 |
__strftime()__ and converts the character string pointed |
|
|
29 |
to by ''s'' to values which are stored in the __tm__ |
|
|
30 |
structure pointed to by ''tm'', using the format |
|
|
31 |
specified by ''format''. Here ''format'' is a |
|
|
32 |
character string that consists of field descriptors and text |
|
|
33 |
characters, reminiscent of scanf(3). Each field |
|
|
34 |
descriptor consists of a __%__ character followed by |
|
|
35 |
another character that specifies the replacement for the |
|
|
36 |
field descriptor. All other characters in the ''format'' |
|
|
37 |
string must have a matching character in the input string. |
|
|
38 |
Exceptions are white spaces in the format string which can |
|
|
39 |
match zero or more white space characters in the input |
|
|
40 |
string. |
|
|
41 |
|
|
|
42 |
|
|
|
43 |
The __strptime()__ function processes the input string |
|
|
44 |
from right to left. Each of the three possible input |
|
|
45 |
elements (white space, literal, or format) are handled one |
|
|
46 |
after the other. If the input cannot be matched to the |
|
|
47 |
format string the function stops. The remainder of the |
|
|
48 |
format and input strings are not processed. |
|
|
49 |
|
|
|
50 |
|
|
|
51 |
The following field descriptors are supported: |
|
|
52 |
|
|
|
53 |
|
|
|
54 |
__%%__ |
|
|
55 |
|
|
|
56 |
|
|
|
57 |
the __%__ character |
|
|
58 |
|
|
|
59 |
|
|
|
60 |
__%a__ or __%A__ |
|
|
61 |
|
|
|
62 |
|
|
|
63 |
day of week, using locale's weekday names; either the |
|
|
64 |
abbreviated or full name may be specified |
|
|
65 |
|
|
|
66 |
|
|
|
67 |
__%b__ or __%B__ or __%h__ |
|
|
68 |
|
|
|
69 |
|
|
|
70 |
month, using locale's month names; either the abbreviated or |
|
|
71 |
full name may be specified |
|
|
72 |
|
|
|
73 |
|
|
|
74 |
__%c__ |
|
|
75 |
|
|
|
76 |
|
|
|
77 |
date and time as %x %X |
|
|
78 |
|
|
|
79 |
|
|
|
80 |
__%C__ |
|
|
81 |
|
|
|
82 |
|
|
|
83 |
date and time, in locale's long-format date and time |
|
|
84 |
representation |
|
|
85 |
|
|
|
86 |
|
|
|
87 |
__%d__ or __%e__ |
|
|
88 |
|
|
|
89 |
|
|
|
90 |
day of month (1-31; leading zeroes are permitted but not |
|
|
91 |
required) |
|
|
92 |
|
|
|
93 |
|
|
|
94 |
__%D__ |
|
|
95 |
|
|
|
96 |
|
|
|
97 |
date as %m/%d/%y |
|
|
98 |
|
|
|
99 |
|
|
|
100 |
__%H__ or __%k__ |
|
|
101 |
|
|
|
102 |
|
|
|
103 |
hour (0-23; leading zeroes are permitted but not |
|
|
104 |
required) |
|
|
105 |
|
|
|
106 |
|
|
|
107 |
__%I__ or __%l__ |
|
|
108 |
|
|
|
109 |
|
|
|
110 |
hour (0-12; leading zeroes are permitted but not |
|
|
111 |
required) |
|
|
112 |
|
|
|
113 |
|
|
|
114 |
__%j__ |
|
|
115 |
|
|
|
116 |
|
|
|
117 |
day number of year (001-366) |
|
|
118 |
|
|
|
119 |
|
|
|
120 |
__%m__ |
|
|
121 |
|
|
|
122 |
|
|
|
123 |
month number (1-12; leading zeroes are permitted but not |
|
|
124 |
required) |
|
|
125 |
|
|
|
126 |
|
|
|
127 |
__%M__ |
|
|
128 |
|
|
|
129 |
|
|
|
130 |
minute (0-59; leading zeroes are permitted but not |
|
|
131 |
required) |
|
|
132 |
|
|
|
133 |
|
|
|
134 |
__%p__ |
|
|
135 |
|
|
|
136 |
|
|
|
137 |
locale's equivalent of AM or |
|
|
138 |
PM |
|
|
139 |
|
|
|
140 |
|
|
|
141 |
__%r__ |
|
|
142 |
|
|
|
143 |
|
|
|
144 |
time as %I:%M:%S %p |
|
|
145 |
|
|
|
146 |
|
|
|
147 |
__%R__ |
|
|
148 |
|
|
|
149 |
|
|
|
150 |
time as %H:%M |
|
|
151 |
|
|
|
152 |
|
|
|
153 |
__%S__ |
|
|
154 |
|
|
|
155 |
|
|
|
156 |
seconds (0-61; leading zeroes are permitted but not |
|
|
157 |
required. Extra second allowed for leap years) |
|
|
158 |
|
|
|
159 |
|
|
|
160 |
__%T__ |
|
|
161 |
|
|
|
162 |
|
|
|
163 |
time as %H:%M:%S |
|
|
164 |
|
|
|
165 |
|
|
|
166 |
__%w__ |
|
|
167 |
|
|
|
168 |
|
|
|
169 |
weekday number (0-6) with Sunday as the first day of the |
|
|
170 |
week |
|
|
171 |
|
|
|
172 |
|
|
|
173 |
__%x__ |
|
|
174 |
|
|
|
175 |
|
|
|
176 |
date, using locale's date format |
|
|
177 |
|
|
|
178 |
|
|
|
179 |
__%X__ |
|
|
180 |
|
|
|
181 |
|
|
|
182 |
time, using locale's time format |
|
|
183 |
|
|
|
184 |
|
|
|
185 |
__%y__ |
|
|
186 |
|
|
|
187 |
|
|
|
188 |
year within century (0-99; leading zeroes are permitted but |
|
|
189 |
not required. When a century is not otherwise specified, |
|
|
190 |
values in the range 69-99 refer to years in the twentieth |
|
|
191 |
century (1969 to 1999 inclusive); values in the range 00-68 |
|
|
192 |
refer to years in the twenty-first century (2000 to 2068 |
|
|
193 |
inclusive). |
|
|
194 |
|
|
|
195 |
|
|
|
196 |
__%Y__ |
|
|
197 |
|
|
|
198 |
|
|
|
199 |
year, including century (for example, 1988) |
|
|
200 |
|
|
|
201 |
|
|
|
202 |
Case is ignored when matching items such as month or weekday |
|
|
203 |
names. |
|
|
204 |
|
|
|
205 |
|
|
|
206 |
Some field descriptors can be modified by the E and O |
|
|
207 |
modifier characters to indicate that an alternative format |
|
|
208 |
or specification should be used. If the alternative format |
|
|
209 |
or specification does not exist in the current locale, the |
|
|
210 |
unmodified field descriptors is used. |
|
|
211 |
|
|
|
212 |
|
|
|
213 |
The E modifier specifies that the input string may contain |
|
|
214 |
alternative locale-dependent versions of the date and time |
|
|
215 |
representation: |
|
|
216 |
|
|
|
217 |
|
|
|
218 |
__%Ec__ |
|
|
219 |
|
|
|
220 |
|
|
|
221 |
the locale's alternative date and time |
|
|
222 |
representation. |
|
|
223 |
|
|
|
224 |
|
|
|
225 |
__%EC__ |
|
|
226 |
|
|
|
227 |
|
|
|
228 |
the name of the base year (period) in the locale's |
|
|
229 |
alternative representation. |
|
|
230 |
|
|
|
231 |
|
|
|
232 |
__%Ex__ |
|
|
233 |
|
|
|
234 |
|
|
|
235 |
the locale's alternative date representation. |
|
|
236 |
|
|
|
237 |
|
|
|
238 |
__%EX__ |
|
|
239 |
|
|
|
240 |
|
|
|
241 |
the locale's alternative time representation. |
|
|
242 |
|
|
|
243 |
|
|
|
244 |
__%Ey__ |
|
|
245 |
|
|
|
246 |
|
|
|
247 |
the offset from %EC (year only) in the locale's alternative |
|
|
248 |
representation. |
|
|
249 |
|
|
|
250 |
|
|
|
251 |
__%EY__ |
|
|
252 |
|
|
|
253 |
|
|
|
254 |
the full alternative year representation. |
|
|
255 |
|
|
|
256 |
|
|
|
257 |
The O modifier specifies that the numerical input may be in |
|
|
258 |
an alternative locale-dependent format: |
|
|
259 |
|
|
|
260 |
|
|
|
261 |
__%Od__ or __%Oe__ |
|
|
262 |
|
|
|
263 |
|
|
|
264 |
the day of the month using the locale's alternative numeric |
|
|
265 |
symbols; leading zeros are permitted but not |
|
|
266 |
required. |
|
|
267 |
|
|
|
268 |
|
|
|
269 |
__%OH__ |
|
|
270 |
|
|
|
271 |
|
|
|
272 |
the hour (24-hour clock) using the locale's alternative |
|
|
273 |
numeric symbols. |
|
|
274 |
|
|
|
275 |
|
|
|
276 |
__%OI__ |
|
|
277 |
|
|
|
278 |
|
|
|
279 |
the hour (12-hour clock) using the locale's alternative |
|
|
280 |
numeric symbols. |
|
|
281 |
|
|
|
282 |
|
|
|
283 |
__%Om__ |
|
|
284 |
|
|
|
285 |
|
|
|
286 |
the month using the locale's alternative numeric |
|
|
287 |
symbols. |
|
|
288 |
|
|
|
289 |
|
|
|
290 |
__%OM__ |
|
|
291 |
|
|
|
292 |
|
|
|
293 |
the minutes using the locale's alternative numeric |
|
|
294 |
symbols. |
|
|
295 |
|
|
|
296 |
|
|
|
297 |
__%OS__ |
|
|
298 |
|
|
|
299 |
|
|
|
300 |
the seconds using the locale's alternative numeric |
|
|
301 |
symbols. |
|
|
302 |
|
|
|
303 |
|
|
|
304 |
__%OU__ |
|
|
305 |
|
|
|
306 |
|
|
|
307 |
the week number of the year (Sunday as the first day of the |
|
|
308 |
week) using the locale's alternative numeric |
|
|
309 |
symbols. |
|
|
310 |
|
|
|
311 |
|
|
|
312 |
__%Ow__ |
|
|
313 |
|
|
|
314 |
|
|
|
315 |
the number of the weekday (Sunday=0) using the locale's |
|
|
316 |
alternative numeric symbols. |
|
|
317 |
|
|
|
318 |
|
|
|
319 |
__%OW__ |
|
|
320 |
|
|
|
321 |
|
|
|
322 |
the week number of the year (Monday as the first day of the |
|
|
323 |
week) using the locale's alternative numeric |
|
|
324 |
symbols. |
|
|
325 |
|
|
|
326 |
|
|
|
327 |
__%Oy__ |
|
|
328 |
|
|
|
329 |
|
|
|
330 |
the year (offset from %C) using the locale's alternative |
|
|
331 |
numeric symbols. |
|
|
332 |
|
|
|
333 |
|
|
|
334 |
The broken-down time structure ''tm'' is defined in |
|
|
335 |
'''' as follows: |
|
|
336 |
|
|
|
337 |
|
|
|
338 |
struct tm |
|
|
339 |
{ |
|
|
340 |
int tm_sec; /* seconds */ |
|
|
341 |
int tm_min; /* minutes */ |
|
|
342 |
int tm_hour; /* hours */ |
|
|
343 |
int tm_mday; /* day of the month */ |
|
|
344 |
int tm_mon; /* month */ |
|
|
345 |
int tm_year; /* year */ |
|
|
346 |
int tm_wday; /* day of the week */ |
|
|
347 |
int tm_yday; /* day in the year */ |
|
|
348 |
int tm_isdst; /* daylight saving time */ |
|
|
349 |
}; |
|
|
350 |
!!RETURN VALUE |
|
|
351 |
|
|
|
352 |
|
|
|
353 |
The return value of the function is a pointer to the first |
|
|
354 |
character not processed in this function call. In case the |
|
|
355 |
input string contains more characters than required by the |
|
|
356 |
format string the return value points right after the last |
|
|
357 |
consumed input character. In case the whole input string is |
|
|
358 |
consumed the return value points to the NUL byte at the end |
|
|
359 |
of the string. If __strptime()__ fails to match all of |
|
|
360 |
the format string and therefore an error occurred the |
|
|
361 |
function returns __NULL__. |
|
|
362 |
!!NOTES |
|
|
363 |
|
|
|
364 |
|
|
|
365 |
In principle, this function does not initialize __tm__ |
|
|
366 |
but only stores the values specified. This means that |
|
|
367 |
__tm__ should be initialized before the call. Details |
|
|
368 |
differ a bit between different Unix systems. The GNU libc |
|
|
369 |
implementation does not touch those fields which are not |
|
|
370 |
explicitly specified, except that it recomputes the |
|
|
371 |
''tm_wday'' and ''tm_yday'' field if any of the year, |
|
|
372 |
month, or day elements changed. |
|
|
373 |
|
|
|
374 |
|
|
|
375 |
This function is available since libc 4.6.8. Linux libc4 and |
|
|
376 |
libc5 includes define the prototype unconditionally; glibc2 |
|
|
377 |
includes provide a prototype only when _XOPEN_SOURCE or |
|
|
378 |
_GNU_SOURCE are defined. The E and O locale modifier |
|
|
379 |
characters are accepted since libc 5.4.13. The 'y' (year in |
|
|
380 |
century) specification is taken to specify a year in the |
|
|
381 |
20th century by libc4 and libc5. It is taken to be a year in |
|
|
382 |
the range 1950-2049 by glibc 2.0. It is taken to be a year |
|
|
383 |
in 1969-2068 by glibc 2.1. |
|
|
384 |
!!SEE ALSO |
|
|
385 |
|
|
|
386 |
|
|
|
387 |
time(2), scanf(3), setlocale(3), |
|
|
388 |
strftime(3) |
|
|
389 |
---- |