1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199
|
.\" Copyright 1993 Mitchum DSouza <m.dsouza@mrc-apu.cam.ac.uk>
.\"
.\" Permission is granted to make and distribute verbatim copies of this
.\" manual provided the copyright notice and this permission notice are
.\" preserved on all copies.
.\"
.\" Permission is granted to copy and distribute modified versions of this
.\" manual under the conditions for verbatim copying, provided that the
.\" entire resulting derived work is distributed under the terms of a
.\" permission notice identical to this one
.\"
.\" Since the Linux kernel and libraries are constantly changing, this
.\" manual page may be incorrect or out-of-date. The author(s) assume no
.\" responsibility for errors or omissions, or for damages resulting from
.\" the use of the information contained herein. The author(s) may not
.\" have taken the same level of care in the production of this manual,
.\" which is licensed free of charge, as they might when working
.\" professionally.
.\"
.\" Formatted or processed versions of this manual, if unaccompanied by
.\" the source, must acknowledge the copyright and authors of this work.
.\"
.TH STRPTIME 3 "26 September 1994" "GNU" "Linux Programmer's Manual"
.SH NAME
strptime \- convert a string representation of time to a time tm structure
.SH SYNOPSIS
.B #include <time.h>
.sp
.BI "char *strptime(char *" buf ", const char *" format ,
.BI "const struct tm *" tm );
.SH DESCRIPTION
.LP
.IX "strptime function" "" "\fLstrptime()\fP \(em date and time conversion"
.B strptime(\|)
is the complementary function to
.B strftime(\|)
and converts the character string pointed to by
.I buf
to a time value, which is stored in the
.B tm
structure pointed to by
.IR tm ,
using the format specified by
.IR format .
.I format
is a character string that consists of field descriptors and text characters,
reminiscent of
.BR scanf (3).
Each field descriptor consists of a
.B %
character followd by another character that specifies the replacement for the
field descriptor.
All other characters are copied from
.I format
into the result.
The following field descriptors are supported:
.RS
.TP
.B %%
same as
.B %
.TP
.B %a
.PD 0
.TP
.B %A
day of week, using locale's weekday names; either the abbreviated or full name
may be specified
.PD
.TP
.B %b
.PD 0
.TP
.B %B
.TP
.B %h
month, using locale's month names; either the abbreviated or full name
may be specified
.PD
.TP
.B %c
date and time as %x %X
.TP
.B %C
date and time, in locale's long-format date and time representation
.TP
.B %d
.PD 0
.TP
.B %e
day of month (1-31; leading zeroes are permitted but not required)
.PD
.TP
.B %D
date as %m/%d/%y
.TP
.B %H
.PD 0
.TP
.B %k
hour (0-23; leading zeroes are permitted but not required)
.PD
.TP
.B %I
.PD 0
.TP
.B %l
hour (0-12; leading zeroes are permitted but not required)
.PD
.TP
.B %j
day number of year (001-366)
.TP
.B %m
month number (1-12; leading zeroes are permitted but not required)
.TP
.B %M
minute (0-59; leading zeroes are permitted but not required)
.TP
.B %p
locale's equivalent of
.SM AM
or
.SM PM
.TP
.B %r
time as %I:%M:%S %p
.TP
.B %R
time as %H:%M
.TP
.B %S
seconds (0-61; leading zeroes are permitted but not required. Extra second
allowed for leap years)
.TP
.B %T
time as %H:%M:%S
.TP
.B %w
weekday number (0-6) with Sunday as the first day of the week
.TP
.B %x
date, using locale's date format
.TP
.B %X
time, using locale's time format
.TP
.B %y
year within century (0-99; leading zeroes are permitted but not required.
Unfortunately this makes the assumption that we are stuck in the 20th
century as 1900 is automatically added onto this number for the tm_year
field)
.TP
.B %Y
year, including century (for example, 1988)
.RE
.LP
Case is ignored when matching items such as month or weekday names.
.LP
The broken-down time structure \fItm\fP is defined in \fI<time.h>\fP
as follows:
.sp
.RS
.nf
.ne 12
.ta 8n 16n 32n
struct tm
{
int tm_sec; /* seconds */
int tm_min; /* minutes */
int tm_hour; /* hours */
int tm_mday; /* day of the month */
int tm_mon; /* month */
int tm_year; /* year */
int tm_wday; /* day of the week */
int tm_yday; /* day in the year */
int tm_isdst; /* daylight saving time */
};
.ta
.fi
.RE
.SH "RETURN VALUE"
The \fBstrptime()\fP function returns a pointer to the character following
the last character in the string pointed to by
.I buf
\.
.SH "SEE ALSO"
.BR strftime "(3), " time "(2), " setlocale "(3), " scanf (3)
.SH BUGS
.LP
The return values point to static data,
whose contents are overwritten by each call.
.SH NOTES
.LP
This function is only available in libraries newer than version 4.6.5
.PP
The function supports only those locales specified in
.BR locale "(7)"
|