]> git.saurik.com Git - apple/libc.git/blame - stdtime/FreeBSD/strptime.3
Libc-339.tar.gz
[apple/libc.git] / stdtime / FreeBSD / strptime.3
CommitLineData
5b2abdfb
A
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.\"
9385eb3d 26.\" $FreeBSD: src/lib/libc/stdtime/strptime.3,v 1.22 2003/01/04 09:50:04 tjr Exp $
5b2abdfb 27.\" "
9385eb3d 28.Dd January 4, 2003
5b2abdfb
A
29.Dt STRPTIME 3
30.Os
31.Sh NAME
32.Nm strptime
33.Nd parse date and time string
34.Sh LIBRARY
35.Lb libc
36.Sh SYNOPSIS
37.In time.h
38.Ft char *
9385eb3d
A
39.Fo strptime
40.Fa "const char * restrict buf"
41.Fa "const char * restrict format"
42.Fa "struct tm * restrict timeptr"
43.Fc
5b2abdfb
A
44.Sh DESCRIPTION
45The
46.Fn strptime
47function parses the string in the buffer
48.Fa buf
49according to the string pointed to by
50.Fa format ,
51and fills in the elements of the structure pointed to by
52.Fa timeptr .
53The resulting values will be relative to the local time zone.
54Thus, it can be considered the reverse operation of
55.Xr strftime 3 .
56.Pp
57The
58.Fa format
59string consists of zero or more conversion specifications and
60ordinary characters.
61All ordinary characters are matched exactly with the buffer, where
62white space in the format string will match any amount of white space
63in the buffer.
64All conversion specifications are identical to those described in
65.Xr strftime 3 .
66.Pp
67Two-digit year values, including formats
68.Fa %y
69and
70.Fa \&%D ,
71are now interpreted as beginning at 1969 per POSIX requirements.
72Years 69-00 are interpreted in the 20th century (1969-2000), years
7301-68 in the 21st century (2001-2068).
9385eb3d
A
74.Pp
75If the
76.Fa format
77string does not contain enough conversion specifications to completely
78specify the resulting
79.Vt struct tm ,
80the unspecified members of
81.Va timeptr
82are left untouched.
83For example, if
84.Fa format
85is
86.Dq Li "%H:%M:%S" ,
87only
88.Va tm_hour ,
89.Va tm_sec
90and
91.Va tm_min
92will be modified.
93If time relative to today is desired, initialize the
94.Fa timeptr
95structure with today's date before passing it to
96.Fn strptime .
5b2abdfb
A
97.Sh RETURN VALUES
98Upon successful completion,
99.Fn strptime
100returns the pointer to the first character in
101.Fa buf
102that has not been required to satisfy the specified conversions in
103.Fa format .
104It returns
105.Dv NULL
106if one of the conversions failed.
107.Sh SEE ALSO
108.Xr date 1 ,
109.Xr scanf 3 ,
110.Xr strftime 3
111.Sh AUTHORS
112The
113.Fn strptime
114function has been contributed by Powerdog Industries.
115.Pp
116This man page was written by
117.An J\(:org Wunsch .
118.Sh HISTORY
119The
120.Fn strptime
121function appeared in
122.Fx 3.0 .
123.Sh BUGS
124Both the
125.Fa %e
126and
127.Fa %l
128format specifiers may incorrectly scan one too many digits
129if the intended values comprise only a single digit
130and that digit is followed immediately by another digit.
131Both specifiers accept zero-padded values,
132even though they are both defined as taking unpadded values.
133.Pp
134The
135.Fa %p
136format specifier has no effect unless it is parsed
137.Em after
138hour-related specifiers.
139Specifying
140.Fa %l
141without
142.Fa %p
143will produce undefined results.
144Note that 12AM
145(ante meridiem)
146is taken as midnight
147and 12PM
148(post meridiem)
149is taken as noon.
150.Pp
151The
152.Fa %U
153and
154.Fa %W
155format specifiers accept any value within the range 00 to 53
156without validating against other values supplied (like month
157or day of the year, for example).
158.Pp
159The
160.Fa %Z
161format specifier only accepts time zone abbreviations of the local time zone,
162or the value "GMT".
163This limitation is because of ambiguity due to of the over loading of time
164zone abbreviations. One such example is
165.Fa EST
166which is both Eastern Standard Time and Eastern Australia Summer Time.
9385eb3d
A
167.Pp
168The
169.Fn strptime
170function does not correctly handle multibyte characters in the
171.Fa format
172argument.