NAME | SYNOPSIS | DESCRIPTION | RETURN VALUES | USAGE | ATTRIBUTES | SEE ALSO
#include <time.h>char *strptime(const char *buf, const char *format, struct tm *tm);
The strptime() function converts the character string pointed to by buf to values which are stored in the tm structure pointed to by tm, using the format specified by format.
The format argument is composed of zero or more conversion specifications. Each conversion specification is composed of a "%" (percent) character followed by one or two conversion characters which specify the replacement required. One or more white space characters (as specified by isspace(3C)) may precede or follow a conversion specification. There must be white-space or other non-alphanumeric characters between any two conversion specifications.
The following conversion specifications are supported:
Same as %.
Day of week, using the locale's weekday names; either the abbreviated or full name may be specified.
Same as %a.
Month, using the locale's month names; either the abbreviated or full name may be specified.
Same as %b.
Locale's appropriate date and time representation.
Century number [0,99]; leading zero is permitted but not required.
Day of month [1,31]; leading zero is permitted but not required.
Date as %m/%d/%y.
Same as %d.
Same as %b.
Hour (24-hour clock) [0,23]; leading zero is permitted but not required.
Hour (12-hour clock) [1,12]; leading zero is permitted but not required.
Day number of the year [1,366]; leading zeros are permitted but not required.
Month number [1,12]; leading zero is permitted but not required.
Minute [0-59]; leading zero is permitted but not required.
Any white space.
Locale's equivalent of either a.m. or p.m.
Appropriate time representation in the 12-hour clock format with %p.
Time as %H:%M.
Seconds [0,61]; leading zero is permitted but not required. The range of values is [00,61] rather than [00,59] to allow for the occasional leap second and even more occasional double leap second.
Any white space.
Time as %H:%M:%S.
Week number of the year as a decimal number [0,53], with Sunday as the first day of the week; leading zeros are permitted but not required.
Weekday as a decimal number [0,6], with 0 representing Sunday.
Week number of the year as a decimal number [0,53], with Monday as the first day of the week; leading zero is permitted but not required.
Locale's appropriate date representation.
Locale's appropriate time representation.
The year within century. When a century is not otherwise specified, values in the range 69-99 refer to years in the twentieth century (1969 to 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.
Year, including the century (for example, 1993).
Timezone name or no characters if no time zone information exists. Local timezone information is used as though strptime() called tzset() (see ctime(3C)). Errors may not be detected. This behavior is subject to change in a future release.
Some conversion specifications can be modified by the E and O modifier characters to indicate that an alternate format or specification should be used rather than the one normally used by the unmodified specification. If the alternate format or specification does not exist in the current locale, the behavior will be as if the unmodified conversion specification were used.
Locale's alternate appropriate date and time representation.
Name of the base year (era) in the locale's alternate representation.
Locale's alternate date representation.
Locale's alternate time representation.
Offset from %EC (year only) in the locale's alternate representation.
Full alternate year representation.
Day of the month using the locale's alternate numeric symbols.
Same as %Od.
Hour (24-hour clock) using the locale's alternate numeric symbols.
Hour (12-hour clock) using the locale's alternate numeric symbols.
Month using the locale's alternate numeric symbols.
Minutes using the locale's alternate numeric symbols.
Seconds using the locale's alternate numeric symbols.
Week number of the year (Sunday as the first day of the week) using the locale's alternate numeric symbols.
Number of the weekday (Sunday=0) using the locale's alternate numeric symbols.
Week number of the year (Monday as the first day of the week) using the locale's alternate numeric symbols.
Year (offset from %C) in the locale's alternate representation and using the locale's alternate numeric symbols.
A conversion specification that is an ordinary character is executed by scanning the next character from the buffer. If the character scanned from the buffer differs from the one comprising the specification, the specification fails, and the differing and subsequent characters remain unscanned.
A series of specifications composed of %n, %t, white-space characters or any combination is executed by scanning up to the first character that is not white space (which remains unscanned), or until no more characters can be scanned. White space is defined by isspace(3C).
Any other conversion specification is executed by scanning characters until a character matching the next specification is scanned, or until no more characters can be scanned. These characters, except the one matching the next specification, are then compared to the locale values associated with the conversion specifier. If a match is found, values for the appropriate tm structure members are set to values corresponding to the locale information. If no match is found, strptime() fails and no more characters are scanned.
The month names, weekday names, era names, and alternate numeric symbols can consist of any combination of upper and lower case letters. The user can request that the input date or time specification be in a specific language by setting the LC_TIME category using setlocale(3C).
Upon successful completion, strptime() returns a pointer to the character following the last character parsed. Otherwise, a null pointer is returned.
Several "same as" formats, and the special processing of white-space characters are provided in order to ease the use of identical format strings for strftime(3C) and strptime().
See attributes(5) for descriptions of the following attributes:
ATTRIBUTE TYPE | ATTRIBUTE VALUE |
---|---|
MT-Level | MT-Safe |
CSI | Enabled |
NAME | SYNOPSIS | DESCRIPTION | RETURN VALUES | USAGE | ATTRIBUTES | SEE ALSO