]> git.saurik.com Git - apple/libc.git/blob - stdtime/strptime.3
Libc-262.3.2.tar.gz
[apple/libc.git] / stdtime / strptime.3
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: src/lib/libc/stdtime/strptime.3,v 1.9.2.7 2001/12/14 18:33:59 ru Exp $
27 .\" "
28 .Dd May 8, 1997
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 *
39 .Fn strptime "const char *buf" "const char *format" "struct tm *timeptr"
40 .Sh DESCRIPTION
41 The
42 .Fn strptime
43 function parses the string in the buffer
44 .Fa buf
45 according to the string pointed to by
46 .Fa format ,
47 and fills in the elements of the structure pointed to by
48 .Fa timeptr .
49 The resulting values will be relative to the local time zone.
50 Thus, it can be considered the reverse operation of
51 .Xr strftime 3 .
52 .Pp
53 The
54 .Fa format
55 string consists of zero or more conversion specifications and
56 ordinary characters.
57 All ordinary characters are matched exactly with the buffer, where
58 white space in the format string will match any amount of white space
59 in the buffer.
60 All conversion specifications are identical to those described in
61 .Xr strftime 3 .
62 .Pp
63 Two-digit year values, including formats
64 .Fa %y
65 and
66 .Fa \&%D ,
67 are now interpreted as beginning at 1969 per POSIX requirements.
68 Years 69-00 are interpreted in the 20th century (1969-2000), years
69 01-68 in the 21st century (2001-2068).
70 .Sh RETURN VALUES
71 Upon successful completion,
72 .Fn strptime
73 returns the pointer to the first character in
74 .Fa buf
75 that has not been required to satisfy the specified conversions in
76 .Fa format .
77 It returns
78 .Dv NULL
79 if one of the conversions failed.
80 .Sh SEE ALSO
81 .Xr date 1 ,
82 .Xr scanf 3 ,
83 .Xr strftime 3
84 .Sh AUTHORS
85 The
86 .Fn strptime
87 function has been contributed by Powerdog Industries.
88 .Pp
89 This man page was written by
90 .An J\(:org Wunsch .
91 .Sh HISTORY
92 The
93 .Fn strptime
94 function appeared in
95 .Fx 3.0 .
96 .Sh BUGS
97 Both the
98 .Fa %e
99 and
100 .Fa %l
101 format specifiers may incorrectly scan one too many digits
102 if the intended values comprise only a single digit
103 and that digit is followed immediately by another digit.
104 Both specifiers accept zero-padded values,
105 even though they are both defined as taking unpadded values.
106 .Pp
107 The
108 .Fa %p
109 format specifier has no effect unless it is parsed
110 .Em after
111 hour-related specifiers.
112 Specifying
113 .Fa %l
114 without
115 .Fa %p
116 will produce undefined results.
117 Note that 12AM
118 (ante meridiem)
119 is taken as midnight
120 and 12PM
121 (post meridiem)
122 is taken as noon.
123 .Pp
124 The
125 .Fa %U
126 and
127 .Fa %W
128 format specifiers accept any value within the range 00 to 53
129 without validating against other values supplied (like month
130 or day of the year, for example).
131 .Pp
132 The
133 .Fa %Z
134 format specifier only accepts time zone abbreviations of the local time zone,
135 or the value "GMT".
136 This limitation is because of ambiguity due to of the over loading of time
137 zone abbreviations. One such example is
138 .Fa EST
139 which is both Eastern Standard Time and Eastern Australia Summer Time.