xref: /freebsd/lib/libc/stdtime/strptime.3 (revision 4cf49a43559ed9fdad601bdcccd2c55963008675)
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 May 8, 1997
29.Dt STRPTIME 3
30.Os
31.Sh NAME
32.Nm strptime
33.Nd parse date and time string
34.Sh SYNOPSIS
35.Fd #include <time.h>
36.Ft char *
37.Fn strptime "const char *buf" "const char *format" "struct tm *timeptr"
38.Sh DESCRIPTION
39The
40.Fn strptime
41function parses the string in the buffer
42.Fa buf
43according to the string pointed to by
44.Fa format ,
45and fills in the elements of the structure pointed to by
46.Fa timeptr .
47The resulting values will be relative to the local time zone.
48Thus, it can be considered the reverse operation of
49.Xr strftime 3 .
50.Pp
51The
52.Fa format
53string consists of zero or more conversion specifications and
54ordinary characters.
55All ordinary characters are matched exactly with the buffer, where
56white space in the format string will match any amount of white space
57in the buffer.
58All conversion specifications are identical to those described in
59.Xr strftime 3 .
60.Pp
61Two-digit year values, including formats
62.Fa %y
63and
64.Fa %D ,
65are now interpreted as beginning at 1969 per POSIX requirements.
66Years 69-00 are interpreted in the 20th century (1969-2000), years
6701-68 in the 21st century (2001-2068).
68.Sh RETURN VALUES
69Upon successful completion,
70.Fn strptime
71returns the pointer to the first character in
72.Fa buf
73that has not been required to satisfy the specified conversions in
74.Fa format .
75It returns
76.Dv NULL
77if one of the conversions failed.
78.Sh SEE ALSO
79.Xr date 1 ,
80.Xr scanf 3 ,
81.Xr strftime 3
82.Sh AUTHORS
83The
84.Fn strptime
85function has been contributed by Powerdog Industries.
86.Pp
87This man page was written by
88.ie t J\(:org Wunsch.
89.el Joerg Wunsch.
90.Sh HISTORY
91The
92.Fn strptime
93function appeared in
94.Fx 3.0 .
95.Pp
96.Sh BUGS
97The
98.Fa %Z
99format specifier only accepts time zone abbreviations of the local time zone,
100or the value "GMT".
101This limitation is because of ambiguity due to of the over loading of time
102zone abbreviations.  One such example is
103.Fa EST
104which is both Eastern Standard Time and Eastern Australia Summer Time.
105