xref: /netbsd-src/lib/libc/time/strptime.3 (revision fdecd6a253f999ae92b139670d9e15cc9df4497c)
1.\"	$NetBSD: strptime.3,v 1.1 1997/05/25 19:29:37 kleink Exp $
2.\"
3.\" Copyright (c) 1997 The NetBSD Foundation, Inc.
4.\" All rights reserved.
5.\"
6.\" This file was contributed to The NetBSD Foundation by Klaus Klein.
7.\"
8.\" Redistribution and use in source and binary forms, with or without
9.\" modification, are permitted provided that the following conditions
10.\" are met:
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.
16.\" 3. All advertising materials mentioning features or use of this software
17.\"    must display the following acknowledgement:
18.\"        This product includes software developed by the NetBSD
19.\"        Foundation, Inc. and its contributors.
20.\" 4. Neither the name of The NetBSD Foundation nor the names of its
21.\"    contributors may be used to endorse or promote products derived
22.\"    from this software without specific prior written permission.
23.\"
24.\" THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
25.\" ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
26.\" TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
27.\" PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE
28.\" LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
29.\" CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
30.\" SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
31.\" INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
32.\" CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
33.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
34.\" POSSIBILITY OF SUCH DAMAGE.
35.\"
36.Dd April 23, 1997
37.Os
38.Dt STRPTIME 3
39.Sh NAME
40.Nm strptime
41.Nd converts a character string to a time value
42.Sh SYNOPSIS
43.Fd #include <time.h>
44.Ft char *
45.Fn strptime "const char *buf" "const char *format" "struct tm *tm"
46.Sh DESCRIPTION
47The
48.Nm
49function converts the character string pointed to by
50.Fa buf
51to values which are stored in the ``tm'' structure pointed to by
52.Fa tm ,
53using the format specified by
54.Fa format .
55.Pp
56The
57.Fa format
58string consists of zero or more conversion specifications and
59ordinary characters.  All ordinary characters are copied directly into
60the buffer.  A conversion specification consists of a percent sign `%'
61followed by one or two conversion characters which specify the replacement
62required. There must be white-space or other non-alphanumeric characters
63between any two conversion specifications.
64.Pp
65The LC_TIME category defines the locale values for the conversion
66specifications. The following conversion specifications are supported:
67.Bl -tag -width "xxxx"
68.It Cm \&%a
69the day of week, using the locale's weekday names;
70either the abbreviated or full name may be specified.
71.It Cm \&%A
72the same as
73.Cm \&%a .
74.It Cm \&%b
75the month, using the locale's month names;
76either the abbreviated or full name may be specified.
77.It Cm \&%B
78the same as
79.Cm \&%b .
80.It Cm \&%c
81the date and time, using the locale's date and time format.
82.It Cm \&%C
83the century number [0,99];
84leading zeros are permitted but not required.
85.It Cm \&%d
86the day of month [1,31];
87leading zeros are permitted but required.
88.It Cm \&%D
89the date as %m/%d/%y.
90.It Cm \&%e
91the same as
92.Cm \&%d .
93.It Cm \&%h
94the same as
95.Cm \&%b .
96.It Cm \&%H
97the hour (24-hour clock) [0,23];
98leading zeros are permitted but not required.
99.It Cm \&%I
100the hour (12-hour clock) [1,12];
101leading zeros are permitted but not required.
102.It Cm \&%j
103the day number of the year [1,366];
104leading zeros are permitted but not required.
105.It Cm \&%k
106the same as
107.Cm \&%H .
108.It Cm \&%l
109the same as
110.Cm \&%I .
111.It Cm \&%m
112the month number [1,12];
113leading zeros are permitted but not required.
114.It Cm \&%M
115the minute [0,59];
116leading zeros are permitted but not required.
117.It Cm \&%n
118any white-space
119.It Cm \&%p
120the locale's equivalent of a.m. or p.m..
121.It Cm \&%r
122the time (12-hour clock) with %p, using the locale's time format.
123.It Cm \&%R
124the time as %H:%M.
125.It Cm \&%S
126the seconds [0,61];
127leading zeros are permitted but not required.
128.It Cm \&%t
129any white-space
130.It Cm \&%T
131the time as %H:%M:%S.
132.It Cm \&%U
133the week number of the year (Sunday as the first day of the week)
134as a decimal number [0,53];
135leading zeros are permitted but not required.
136All days in a year preceding the first Sunday are considered to be in week 0.
137.It Cm \&%w
138the weekday as a decimal number [0,6], with 0 representing Sunday;
139leading zeros are permitted but not required.
140.It Cm \&%W
141the week number of the year (Monday as the first day of the week)
142as a decimal number [0,53];
143leading zeros are permitted but not required.
144All days in a year preceding the first Monday are considered to be in week 0.
145.It Cm \&%x
146the date, using the locale's date format.
147.It Cm \&%X
148the time, using the locale's time format.
149.It Cm \&%y
150the year within the century [0,99];
151leading zeros are permitted but not required.
152.It Cm \&%Y
153the year, including the century (i.e., 1996).
154.It Cm \&%%
155A `%' is written. No argument is converted.
156.El
157.Ss Modified conversion specifications
158For compatibility, certain conversion specifications can be modified
159by the
160.Cm E
161and
162.Cm O
163modifier characters to indicate that an alternative format or specification
164should be used rather than the one normally used by the unmodified
165conversion specification. As there are currently neither alternative formats
166nor specifications supported by the system, the behavior will be as if the
167unmodified conversion specification were used.
168.Sh RETURN VALUES
169If successful, the
170.Nm
171function returns a pointer to the character following the last character
172parsed. Otherwise, a null pointer is returned.
173.Sh SEE ALSO
174.Xr strftime 3
175.Sh STANDARDS
176The
177.Fn strptime
178function conforms to
179.St -xpg4 .
180