1STRPTIME(P)                POSIX Programmer's Manual               STRPTIME(P)
2
3
4

NAME

6       strptime - date and time conversion
7

SYNOPSIS

9       #include <time.h>
10
11       char *strptime(const char *restrict buf, const char *restrict format,
12              struct tm *restrict tm);
13
14

DESCRIPTION

16       The  strptime()  function shall convert the character string pointed to
17       by buf to values which are stored in the tm structure pointed to by tm,
18       using the format specified by format.
19
20       The  format  is  composed of zero or more directives. Each directive is
21       composed of one of the following: one or  more  white-space  characters
22       (as  specified  by isspace()); an ordinary character (neither '%' nor a
23       white-space character); or a conversion specification.  Each conversion
24       specification  is  composed of a '%' character followed by a conversion
25       character which specifies the  replacement  required.  The  application
26       shall  ensure that there is white-space or other non-alphanumeric char‐
27       acters between any two conversion specifications. The following conver‐
28       sion specifications are supported:
29
30       %a     The  day  of  the week, using the locale's weekday names; either
31              the abbreviated or full name may be specified.
32
33       %A     Equivalent to %a .
34
35       %b     The month, using the locale's month names; either  the  abbrevi‐
36              ated or full name may be specified.
37
38       %B     Equivalent to %b .
39
40       %c     Replaced  by  the locale's appropriate date and time representa‐
41              tion.
42
43       %C     The century number [00,99]; leading zeros are permitted but  not
44              required.
45
46       %d     The  day  of  the month [01,31]; leading zeros are permitted but
47              not required.
48
49       %D     The date as %m / %d / %y .
50
51       %e     Equivalent to %d .
52
53       %h     Equivalent to %b .
54
55       %H     The hour (24-hour clock) [00,23]; leading  zeros  are  permitted
56              but not required.
57
58       %I     The  hour  (12-hour  clock) [01,12]; leading zeros are permitted
59              but not required.
60
61       %j     The day number of the year [001,366]; leading zeros are  permit‐
62              ted but not required.
63
64       %m     The  month  number  [01,12]; leading zeros are permitted but not
65              required.
66
67       %M     The  minute  [00,59];  leading  zeros  are  permitted  but   not
68              required.
69
70       %n     Any white space.
71
72       %p     The locale's equivalent of a.m or p.m.
73
74       %r     12-hour clock time using the AM/PM notation if t_fmt_ampm is not
75              an empty string in the LC_TIME portion of the current locale; in
76              the POSIX locale, this shall be equivalent to %I : %M : %S %p .
77
78       %R     The time as %H : %M .
79
80       %S     The  seconds  [00,60];  leading  zeros  are  permitted  but  not
81              required.
82
83       %t     Any white space.
84
85       %T     The time as %H : %M : %S .
86
87       %U     The week number of the year (Sunday as  the  first  day  of  the
88              week)  as  a decimal number [00,53]; leading zeros are permitted
89              but not required.
90
91       %w     The weekday as a decimal number [0,6], with 0 representing  Sun‐
92              day; leading zeros are permitted but not required.
93
94       %W     The  week  number  of  the  year (Monday as the first day of the
95              week) as a decimal number [00,53]; leading zeros  are  permitted
96              but not required.
97
98       %x     The date, using the locale's date format.
99
100       %X     The time, using the locale's time format.
101
102       %y     The  year within century. When a century is not otherwise speci‐
103              fied, values in the range [69,99] shall refer to years  1969  to
104              1999  inclusive,  and values in the range [00,68] shall refer to
105              years 2000 to 2068 inclusive; leading zeros shall  be  permitted
106              but shall not be required.
107
108       Note:
109              It  is expected that in a future version of IEEE Std 1003.1-2001
110              the default century inferred from a 2-digit  year  will  change.
111              (This  would  apply  to all commands accepting a 2-digit year as
112              input.)
113
114
115       %Y     The year, including the century (for example, 1988).
116
117       %%     Replaced by % .
118
119
120   Modified Conversion Specifiers
121       Some conversion specifiers can be modified by  the  E  and  O  modifier
122       characters  to  indicate  that  an  alternative format or specification
123       should be used rather than the one normally used by the unmodified con‐
124       version  specifier. If the alternative format or specification does not
125       exist in the current locale, the behavior shall be as if the unmodified
126       conversion specification were used.
127
128       %Ec    The  locale's  alternative appropriate date and time representa‐
129              tion.
130
131       %EC    The name of the base year (period) in the  locale's  alternative
132              representation.
133
134       %Ex    The locale's alternative date representation.
135
136       %EX    The locale's alternative time representation.
137
138       %Ey    The offset from %EC (year only) in the locale's alternative rep‐
139              resentation.
140
141       %EY    The full alternative year representation.
142
143       %Od    The day of the month using the locale's alternative numeric sym‐
144              bols; leading zeros are permitted but not required.
145
146       %Oe    Equivalent to %Od .
147
148       %OH    The  hour (24-hour clock) using the locale's alternative numeric
149              symbols.
150
151       %OI    The hour (12-hour clock) using the locale's alternative  numeric
152              symbols.
153
154       %Om    The month using the locale's alternative numeric symbols.
155
156       %OM    The minutes using the locale's alternative numeric symbols.
157
158       %OS    The seconds using the locale's alternative numeric symbols.
159
160       %OU    The  week  number  of  the  year (Sunday as the first day of the
161              week) using the locale's alternative numeric symbols.
162
163       %Ow    The number of the weekday (Sunday=0) using the locale's alterna‐
164              tive numeric symbols.
165
166       %OW    The  week  number  of  the  year (Monday as the first day of the
167              week) using the locale's alternative numeric symbols.
168
169       %Oy    The year (offset  from  %C  )  using  the  locale's  alternative
170              numeric symbols.
171
172
173       A  conversion  specification composed of white-space characters is exe‐
174       cuted by scanning input up to the first character that  is  not  white-
175       space  (which  remains  unscanned),  or until no more characters can be
176       scanned.
177
178       A conversion specification that is an ordinary character is executed by
179       scanning  the  next character from the buffer. If the character scanned
180       from the buffer differs from the  one  comprising  the  directive,  the
181       directive  fails,  and  the  differing and subsequent characters remain
182       unscanned.
183
184       A series of conversion specifications composed of %n , %t , white-space
185       characters,  or any combination is executed by scanning up to the first
186       character that is not white space (which remains unscanned),  or  until
187       no more characters can be scanned.
188
189       Any  other  conversion specification is executed by scanning characters
190       until a character matching the next directive is scanned, or  until  no
191       more characters can be scanned. These characters, except the one match‐
192       ing the next directive, are then compared to the locale values  associ‐
193       ated with the conversion specifier. If a match is found, values for the
194       appropriate tm structure members are set to values corresponding to the
195       locale  information. Case is ignored when matching items in buf such as
196       month or weekday names. If no match is found, strptime() fails  and  no
197       more characters are scanned.
198

RETURN VALUE

200       Upon  successful  completion,  strptime() shall return a pointer to the
201       character following the  last  character  parsed.   Otherwise,  a  null
202       pointer shall be returned.
203

ERRORS

205       No errors are defined.
206
207       The following sections are informative.
208

EXAMPLES

210       None.
211

APPLICATION USAGE

213       Several  "equivalent  to"  formats and the special processing of white-
214       space characters are provided in order to ease  the  use  of  identical
215       format strings for strftime() and strptime().
216
217       Applications should use %Y (4-digit years) in preference to %y (2-digit
218       years).
219
220       It is unspecified whether multiple calls to strptime() using  the  same
221       tm structure will update the current contents of the structure or over‐
222       write all contents of the structure.   Conforming  applications  should
223       make  a  single call to strptime() with a format and all data needed to
224       completely specify the date and time being converted.
225

RATIONALE

227       None.
228

FUTURE DIRECTIONS

230       The strptime() function is expected to be mandatory in the next version
231       of this volume of IEEE Std 1003.1-2001.
232

SEE ALSO

234       scanf()  ,  strftime()  ,  time()  ,  the  Base  Definitions  volume of
235       IEEE Std 1003.1-2001, <time.h>
236
238       Portions of this text are reprinted and reproduced in  electronic  form
239       from IEEE Std 1003.1, 2003 Edition, Standard for Information Technology
240       -- Portable Operating System Interface (POSIX),  The  Open  Group  Base
241       Specifications  Issue  6,  Copyright  (C) 2001-2003 by the Institute of
242       Electrical and Electronics Engineers, Inc and The Open  Group.  In  the
243       event of any discrepancy between this version and the original IEEE and
244       The Open Group Standard, the original IEEE and The Open Group  Standard
245       is  the  referee document. The original Standard can be obtained online
246       at http://www.opengroup.org/unix/online.html .
247
248
249
250IEEE/The Open Group                  2003                          STRPTIME(P)
Impressum