 |
Index for Section 3 |
|
 |
Alphabetical listing for S |
|
 |
Bottom of page |
|
strptime(3)
NAME
strptime - Convert a character string to a time value
SYNOPSIS
#include <time.h>
char *strptime(
const char *buf,
const char *format,
struct tm *tm );
LIBRARY
Standard C Library (libc)
STANDARDS
Interfaces documented on this reference page conform to industry standards
as follows:
strptime(): XSH4.2
Refer to the standards(5) reference page for more information about
industry standards and associated tags.
PARAMETERS
buf Contains the character string to be converted by the strptime()
function.
format
Specifies the format of the string to be converted by the strptime()
function.
tm Specifies the structure to contain the output of the strptime()
function.
DESCRIPTION
The strptime() function converts the characters pointed to by the buf
parameter to values that are stored in the tm structure, using the format
specified by the format parameter. The strptime() function modifies only
the fields in the tm structure that have corresponding conversion
specifications in the format.
The format parameter can contain zero or more of the following items:
· A conversion specification that directs the conversion of the next
input field. Conversion specifications start with a % (percent sign).
· Any white space character (as determined by the isspace() function)
that matches 0 (zero) or more white space characters in the input
stream.
· Any character except % (percent sign) or a white space character that
must match the next character in the input stream. If the character
read from the input stream is different from the character in the
format parameter, the function stops processing the input stream and
returns a null pointer.
Conversion specifications must be separated by white-space or other non-
alphanumeric characters.
The following conversion specifications are supported:
%a Inputs day of the week, using the locale-dependent weekday name. The
abbreviated or full name may be specified.
%A Same as %a.
%b Inputs the month, using the locale-dependent month name. The
abbreviated or full name may be specified.
%B Same as %b.
%c Inputs the date and time, using the locale-dependent default format.
%C Inputs the century as a decimal number in the range from 00 to 99.
Leading zeros are permitted but not required.
%d Inputs the day of the month as a decimal number in the range from 01 to
31. Leading zeros are permitted but not required.
%D Inputs the date as %m/%d/%y.
%e Same as %d.
%E [Tru64 UNIX] Inputs the year, using the locale-dependent Emperor/Era
name and year format.
%h Same as %b.
%H Inputs the hour based on a 24-hour clock as a decimal number in the
range from 00 to 23. Leading zeros are permitted but not required.
%I Inputs the hour based on a 12-hour clock as a decimal number in the
range from 00 to 12. Leading zeros are permitted but not required.
%j Inputs the day number of the year as a decimal number in the range from
001 to 366. Leading zeros are permitted but not required.
%m Inputs the month number as a decimal number in the range from 01 to 12.
Leading zeros are permitted but not required.
%M Inputs the minute as a decimal number in the range from 00 to 59.
Leading zeros are permitted but not required.
%n Inputs any white space up to and including a newline character.
%N [Tru64 UNIX] Inputs the Emperor/Era name.
%o [Tru64 UNIX] Inputs the Emperor/Era year.
%p Inputs the locale-dependent equivalent of AM or PM.
%r Inputs the 12-hour clock time with an AM/PM notation as defined by the
t_fmt_ampm statement (see locale(4) for details), or, by default,
inputs the time as %I:%M:%S %p.
%R Inputs the time as %H:%M.
%S Inputs the second as a decimal number in the range from 00 to 61.
Leading zeros are permitted but not required.
%t Inputs any white-space up to and including a tab character.
%T Inputs the time as %H:%M:%S.
%U Inputs the week number of the year as a decimal number in the range
from 00 to 53. Sunday is the first day of the week. Leading zeros are
permitted but not required.
%w Inputs the weekday as a decimal number in the range from 0 to 6. Sunday
is the first day of the week. Leading zeros are permitted but not
required.
%W Inputs the week number of the year as a decimal number in the range
from 00 to 53. Monday is the first day of the week. Leading zeros are
permitted but not required.
%x Inputs the date, using the locale-dependent short date format.
%X Inputs the time, using the locale-dependent short time format.
%y Inputs the year (excluding the century). When a century is not
otherwise specified (for example, with %C), values in the range 69-99
refer to years in the twentieth century (1969-1999, inclusive); values
in the range 00-68 refer to years in the twenty-first century (2000 to
2068, inclusive). Leading zeros are permitted but not required.
%Y Inputs the year (including the century), for example, 1991.
%Z [Tru64 UNIX] Inputs the time-zone name.
%% Inputs a % (percent sign) character.
Case is ignored for the following conversion specifications when matching
items such as month or weekday names in buf: %a, %A, %b, %B, %E, %h, %N,
%p, and %r.
Alternative-format Directives
The E and O characters can be used with some of the directives to stipulate
that an alternative format be used, if available. If the alternative format
is not available in the current locale, the modifier will be ignored and
the unmodified behavior for that directive will be followed.
%Ec Inputs the date and time, using the locale-dependent alternative
format.
%EC Inputs the base year (period), using the locale-dependent alternative
format.
%Ex Inputs the date, using the locale-dependent alternative format.
%EX Inputs the time, using the locale-dependent alternative format.
%Ey Inputs the year within the century, using the locale-dependent
alternative format.
%EY Inputs the year (including the century), using the locale-dependent
alternative format.
%Od Inputs the day of the month, using the locale-dependent alternative
format. Leading zeros are permitted but not required.
%Oe Same as %Od.
%OH Inputs the hour (24-hour clock), using the locale-dependent alternative
format.
%OI Inputs the hour (12-hour clock), using the locale-dependent alternative
format.
%Om Inputs the month number, using the locale-dependent alternative format.
%OM Inputs the minute, using the locale-dependent alternative format.
%OS Inputs the second, using the locale-dependent alternative format.
%OU Inputs the week number (Sunday as first day of week), using the
locale-dependent alternative format.
%Ow Inputs the number of the weekday (Sunday=0), using the locale-dependent
alternative format.
%OW Inputs the week number (Monday as first day of week), using the
locale-dependent alternative format.
%Oy Inputs the year (offset from %C) in the locale-dependent alternative
representation and using the locale-dependent alternative numeric
symbols.
A directive consisting of white-space characters is executed by reading
input until reaching the first nonwhite-space character, which is not read,
or until no more characters can be read.
A directive consisting of an ordinary character is executed by reading the
next character from the buf parameter. If the character read from the buf
parameter differs from the character comprising the directive, the
directive fails and the differing character and any characters following it
remain unread. Case is ignored when matching buf items, such as month or
weekday names.
If a conversion fails, the contents of the tm structure are undefined.
In most cases, it is possible to use the same format in the strftime() and
strptime() calls because most of the conversion specifications formats are
identical in both functions.
NOTES
Applications should use %Y (4-digit years) in preference to %y (2-digit
years).
RETURN VALUES
On successful completion, the strptime() function returns a pointer to the
character following the last character parsed. Otherwise, a null pointer is
returned.
ERRORS
The strptime() function sets errno to the specified values for the
following conditions:
[ENOSYS]
The functionality is not supported on this implementation.
SEE ALSO
Functions: scanf(3), strfmon(3), strftime(3), time(3)
Standards: standards(5)
 |
Index for Section 3 |
|
 |
Alphabetical listing for S |
|
 |
Top of page |
|