Copyright (C) 2000-2012 |
Manpages STRPTIMESection: Linux Programmer's Manual (3)Updated: 1994-09-26 Index Return to Main Contents NAMEstrptime - convert a string representation of time to a time tm structureSYNOPSIS#define _XOPEN_SOURCE /* glibc2 needs this */#include <time.h> char *strptime(const char *s, const char *format, struct tm *tm); DESCRIPTIONstrptime() is the complementary function to strftime() and converts the character string pointed to by s to values which are stored in the tm structure pointed to by tm, using the format specified by format. Here format is a character string that consists of field descriptors and text characters, reminiscent of scanf(3). Each field descriptor consists of a % character followed by another character that specifies the replacement for the field descriptor. All other characters in the format string must have a matching character in the input string. Exceptions are white spaces in the format string which can match zero or more white space characters in the input string. The strptime() function processes the input string from right to left. Each of the three possible input elements (white space, literal, or format) are handled one after the other. If the input cannot be matched to the format string the function stops. The remainder of the format and input strings are not processed. The following field descriptors are supported:
Case is ignored when matching items such as month or weekday names. Some field descriptors can be modified by the E and O modifier characters to indicate that an alternative format or specification should be used. If the alternative format or specification does not exist in the current locale, the unmodified field descriptors is used. The E modifier specifies that the input string may contain alternative locale-dependent versions of the date and time representation:
The O modifier specifies that the numerical input may be in an alternative locale-dependent format:
The broken-down time structure tm is defined in <time.h> as follows:
RETURN VALUEThe return value of the function is a pointer to the first character not processed in this function call. In case the input string contains more characters than required by the format string the return value points right after the last consumed input character. In case the whole input string is consumed the return value points to the NUL byte at the end of the string. If strptime() fails to match all of the format string and therefore an error occurred the function returns NULL.NOTESIn principle, this function does not initialize tm but only stores the values specified. This means that tm should be initialized before the call. Details differ a bit between different Unix systems. The GNU libc implementation does not touch those fields which are not explicitly specified, except that it recomputes the tm_wday and tm_yday field if any of the year, month, or day elements changed. This function is available since libc 4.6.8. Linux libc4 and libc5 includes define the prototype unconditionally; glibc2 includes provide a prototype only when _XOPEN_SOURCE or _GNU_SOURCE are defined. The E and O locale modifier characters are accepted since libc 5.4.13. The 'y' (year in century) specification is taken to specify a year in the 20th century by libc4 and libc5. It is taken to be a year in the range 1950-2049 by glibc 2.0. It is taken to be a year in 1969-2068 by glibc 2.1. SEE ALSOtime(2), scanf(3), setlocale(3), strftime(3)
IndexThis document was created by man2html, using the manual pages. Time: 12:56:50 GMT, December 14, 2024 |