1 .\" $NetBSD: strptime.3,v 1.27 2009/05/24 02:30:17 ginsbach Exp $
3 .\" Copyright (c) 1997, 1998, 2008 The NetBSD Foundation, Inc.
4 .\" All rights reserved.
6 .\" This file was contributed to The NetBSD Foundation by Klaus Klein.
8 .\" Redistribution and use in source and binary forms, with or without
9 .\" modification, are permitted provided that the following conditions
11 .\" 1. Redistributions of source code must retain the above copyright
12 .\" notice, this list of conditions and the following disclaimer.
13 .\" 2. Redistributions in binary form must reproduce the above copyright
14 .\" notice, this list of conditions and the following disclaimer in the
15 .\" documentation and/or other materials provided with the distribution.
17 .\" THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
18 .\" ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
19 .\" TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
20 .\" PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
21 .\" BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
22 .\" CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
23 .\" SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
24 .\" INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
25 .\" CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
26 .\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
27 .\" POSSIBILITY OF SUCH DAMAGE.
34 .Nd converts a character string to a time value
40 .Fn strptime "const char * restrict buf" "const char * restrict format" "struct tm * restrict tm"
44 function converts the character string pointed to by
46 to values which are stored in the
48 structure pointed to by
50 using the format specified by
55 string consists of zero or more conversion specifications, whitespace
56 characters as defined by
58 and ordinary characters.
59 All ordinary characters in
61 are compared directly against the corresponding characters in
63 comparisons which fail will cause
66 Whitespace characters in
68 match any number of whitespace characters in
72 A conversion specification consists of a percent sign
75 or two conversion characters which specify the replacement required.
76 There must be white-space or other non-alphanumeric characters between any
77 two conversion specifications.
79 Conversion of alphanumeric strings (such as month and weekday names) is
80 done without regard to case.
81 Conversion specifications which cannot be matched will cause
85 The LC_TIME category defines the locale values for the conversion
87 The following conversion specifications are supported:
88 .Bl -tag -width "xxxx"
90 the day of week, using the locale's weekday names;
91 either the abbreviated or full name may be specified.
96 the month, using the locale's month names;
97 either the abbreviated or full name may be specified.
102 the date and time, using the locale's date and time format.
104 the century number [0,99];
105 leading zeros are permitted but not required.
106 This conversion should be used in conjunction with the \&%y conversion.
108 the day of month [1,31];
109 leading zeros are permitted but not required.
111 the date as %m/%d/%y.
117 (the ISO 8601 date format).
119 the year corresponding to the ISO week number, without the century.
126 the year corresponding to the ISO week number, with the century.
136 the hour (24-hour clock) [0,23];
137 leading zeros are permitted but not required.
139 the hour (12-hour clock) [1,12];
140 leading zeros are permitted but not required.
142 the day number of the year [1,366];
143 leading zeros are permitted but not required.
151 the month number [1,12];
152 leading zeros are permitted but not required.
155 leading zeros are permitted but not required.
157 any white-space, including none.
159 the locale's equivalent of a.m. or p.m.
161 the time (12-hour clock) with %p, using the locale's time format.
166 leading zeros are permitted but not required.
168 the number of seconds since the Epoch, UTC (see
176 any white-space, including none.
178 the time as %H:%M:%S.
180 the day of the week as a decimal number, where Monday = 1.
187 the week number of the year (Sunday as the first day of the week)
188 as a decimal number [0,53];
189 leading zeros are permitted but not required.
190 All days in a year preceding the first Sunday are considered to be in week 0.
192 the ISO 8601:1988 week number as a decimal number.
193 If the week (starting on Monday) that contains January 1 has more than
194 three days in the new year, then it is considered the first week of the
196 If it has fewer than four days in the new year, then it is considered
197 the last week of the previous year.
198 Weeks are numbered from 1 to 53.
205 the weekday as a decimal number [0,6], with 0 representing Sunday;
206 leading zeros are permitted but not required.
208 the week number of the year (Monday as the first day of the week)
209 as a decimal number [0,53];
210 leading zeros are permitted but not required.
211 All days in a year preceding the first Monday are considered to be in week 0.
213 the date, using the locale's date format.
215 the time, using the locale's time format.
217 the year within the 20th century [69,99] or the 21st century [0,68];
218 leading zeros are permitted but not required.
219 If specified in conjunction
220 with \&%C, specifies the year [0,99] within that century.
222 the year, including the century (i.e., 1996).
224 an ISO 8601 or RFC-2822 timezone specification.
225 This is one of the following:
227 Coordinated Universal Time
237 .Pq Ql Greenwich Mean Time ,
239 .Pq Ql Universal Time ,
243 a three character US timezone specified as:
253 with the first letter standing for
263 and the second letter standing for
274 a single letter military timezone specified as:
288 timezone name or no characters when time zone information is unavailable.
295 matches a literal `%'.
296 No argument is converted.
298 .Ss Modified conversion specifications
299 For compatibility, certain conversion specifications can be modified
304 modifier characters to indicate that an alternative format or specification
305 should be used rather than the one normally used by the unmodified
306 conversion specification.
307 As there are currently neither alternative formats
308 nor specifications supported by the system, the behavior will be as if the
309 unmodified conversion specification were used.
311 Case is ignored when matching string items in
313 such as month and weekday names.
317 function returns a pointer to the character following the last character
319 Otherwise, a null pointer is returned.
333 format specifier only accepts timezone
334 abbreviations of the local timezone,
337 This limitation is caused by the ambiguity
338 of overloaded timezone abbreviations,
339 for example EST is both Eastern Standard
340 Time and Eastern Australia Summer Time.