]> git.saurik.com Git - apple/libc.git/blame_incremental - stdtime/FreeBSD/strptime.3
Libc-1439.100.3.tar.gz
[apple/libc.git] / stdtime / FreeBSD / strptime.3
... / ...
CommitLineData
1.\"
2.\" Copyright (c) 1997 Joerg Wunsch
3.\"
4.\" All rights reserved.
5.\"
6.\" Redistribution and use in source and binary forms, with or without
7.\" modification, are permitted provided that the following conditions
8.\" are met:
9.\" 1. Redistributions of source code must retain the above copyright
10.\" notice, this list of conditions and the following disclaimer.
11.\" 2. Redistributions in binary form must reproduce the above copyright
12.\" notice, this list of conditions and the following disclaimer in the
13.\" documentation and/or other materials provided with the distribution.
14.\"
15.\" THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY EXPRESS OR
16.\" IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
17.\" OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
18.\" IN NO EVENT SHALL THE DEVELOPERS BE LIABLE FOR ANY DIRECT, INDIRECT,
19.\" INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
20.\" NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
21.\" DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
22.\" THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
23.\" (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
24.\" THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
25.\"
26.\" $FreeBSD$
27.\" "
28.Dd October 2, 2014
29.Dt STRPTIME 3
30.Os
31.Sh NAME
32.Nm strptime ,
33.Nm strptime_l
34.Nd parse date and time string
35.Sh LIBRARY
36.Lb libc
37.Sh SYNOPSIS
38.In time.h
39.Ft char *
40.Fo strptime
41.Fa "const char * restrict buf"
42.Fa "const char * restrict format"
43.Fa "struct tm * restrict timeptr"
44.Fc
45.In time.h
46.In xlocale.h
47.Ft char *
48.Fn strptime_l "const char * restrict buf" "const char * restrict format" "struct tm * restrict timeptr" "locale_t loc"
49.Sh DESCRIPTION
50The
51.Fn strptime
52function parses the string in the buffer
53.Fa buf
54according to the string pointed to by
55.Fa format ,
56and fills in the elements of the structure pointed to by
57.Fa timeptr .
58The resulting values will be relative to the local time zone.
59Thus, it can be considered the reverse operation of
60.Xr strftime 3 .
61The
62.Fn strptime_l
63function does the same as
64.Fn strptime ,
65but takes an explicit locale rather than using the current locale.
66.Pp
67The
68.Fa format
69string consists of zero or more conversion specifications and
70ordinary characters.
71All ordinary characters are matched exactly with the buffer, where
72white space in the format string will match any amount of white space
73in the buffer.
74All conversion specifications are identical to those described in
75.Xr strftime 3 .
76.Pp
77Two-digit year values, including formats
78.Fa %y
79and
80.Fa \&%D ,
81are now interpreted as beginning at 1969 per POSIX requirements.
82Years 69-00 are interpreted in the 20th century (1969-2000), years
8301-68 in the 21st century (2001-2068).
84The
85.Fa \&%U
86and
87.Fa %W
88format specifiers accept any value within the range 00 to 53.
89.Pp
90If the
91.Fa format
92string does not contain enough conversion specifications to completely
93specify the resulting
94.Vt struct tm ,
95the unspecified members of
96.Va timeptr
97are left untouched.
98For example, if
99.Fa format
100is
101.Dq Li "%H:%M:%S" ,
102only
103.Va tm_hour ,
104.Va tm_sec
105and
106.Va tm_min
107will be modified.
108If time relative to today is desired, initialize the
109.Fa timeptr
110structure with today's date before passing it to
111.Fn strptime .
112.Sh RETURN VALUES
113Upon successful completion,
114.Fn strptime
115returns the pointer to the first character in
116.Fa buf
117that has not been required to satisfy the specified conversions in
118.Fa format .
119It returns
120.Dv NULL
121if one of the conversions failed.
122.Fn strptime_l
123returns the same values as
124.Fn strptime .
125.Sh LEGACY DESCRIPTION
126In legacy mode, the
127.Fa %Y
128format specifier expects exactly 4 digits (leaving any trailing digits for the
129next specifier).
130.Sh SEE ALSO
131.Xr date 1 ,
132.Xr scanf 3 ,
133.Xr strftime 3 ,
134.Xr xlocale 3
135.Sh HISTORY
136The
137.Fn strptime
138function appeared in
139.Fx 3.0 .
140.Sh AUTHORS
141The
142.Fn strptime
143function has been contributed by Powerdog Industries.
144.Pp
145This man page was written by
146.An J\(:org Wunsch .
147.Sh BUGS
148Both the
149.Fa %e
150and
151.Fa %l
152format specifiers may incorrectly scan one too many digits
153if the intended values comprise only a single digit
154and that digit is followed immediately by another digit.
155Both specifiers accept zero-padded values,
156even though they are both defined as taking unpadded values.
157.Pp
158The
159.Fa %p
160format specifier has no effect unless it is parsed
161.Em after
162hour-related specifiers.
163Specifying
164.Fa %l
165without
166.Fa %p
167will produce undefined results.
168Note that 12AM
169(ante meridiem)
170is taken as midnight
171and 12PM
172(post meridiem)
173is taken as noon.
174.Pp
175The
176.Fa %Z
177format specifier only accepts time zone abbreviations of the local time zone,
178or the value "GMT".
179This limitation is because of ambiguity due to of the over loading of time
180zone abbreviations.
181One such example is
182.Fa EST
183which is both Eastern Standard Time and Eastern Australia Summer Time.
184.Pp
185The
186.Fn strptime
187function does not correctly handle multibyte characters in the
188.Fa format
189argument.