Definition | #include <time.h> char *strptime(const char *buf, const char *format, struct tm *tm);
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Parameters | const char *buf Date and time string to be converted. struct tm *tm Result structure in which the converted individual date and time values are stored. const char *format The format string contains none, one or more conversion directives. Each conversion directive comprises one of the following elements: Each conversion specification consists of a % sign followed by a conversion character which specifies the desired conversion. Each conversion specification consists of a % character followed by a conversion character that specifies the desired conversion. With conversion specifications that expect a numeric value, the string to be converted may contain not more digits than specified in the format description. I.e. additional leading zeroes are not allowed. If between two conversion specifications there is neither a white-space character nor an non-alphanumeric character, the numbers of digits even must be the same as in the format description. The following conversion characters are supported:
A conversion directive comprising white-space characters is implemented by reading the input up to the first character that is not a white-space character (this character remains unread) or until no further characters exist. A conversion directive comprising a standard character is implemented by reading the next character from the buffer. If the character read from the buffer does not match the character in the conversion directive, the action fails and the buffer character and all subsequent characters remain unread. A sequence of conversion directives comprising %n, %t, white-space characters, and combinations thereof is implemented by reading up to the first character that is not a white-space character (this character remains unread) or until no further characters exist. All other conversion specifications are implemented by reading all characters until a character matching the next conversion directive is read (this character remains in the buffer) or until no further characters exist. The characters that have been read are then compared with the values in the locale that correspond to the conversion specification. If the appropriate value is found in the locale, the corresponding structure elements of the | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Return val. | Pointer to the character behind the last character read | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
if successful | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
NULL pointer | in all other cases | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Note | The special handling of white-space characters and many “identical formats” should make it easier to implement identical format strings for | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
See also | scanf, strftime, time. |