United States-English |
|
|
HP-UX Reference > Sstrptime(3C)HP-UX 11i Version 3: February 2007 |
|
NAMEstrptime() — date and time conversion DESCRIPTIONThe 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 is composed of zero or more directives. Each directive is composed of one of the following: one or more white-space characters (as specified by the isspace() function); an ordinary character (neither % nor a white-space character); or a conversion specification. Each conversion specification is composed of a % character followed by a conversion character which specifies the replacement required. There must be whitespace or other non-alphanumeric characters between any two conversion specifications. The following conversion specifications are supported:
Modified DirectivesSome directives can be modified by the E and O modifier characters to indicate that an alternative format or specification should be used rather than the one normally used by the unmodified directive. If the alternative format or specification does not exist in the current locale, the behavior will be as if the unmodified directive were used.
A directive composed of whitespace characters is executed by scanning input up to the first character that is not whitespace (which remains unscanned), or until no more characters can be scanned. A directive 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 directive, the directive fails, and the differing and subsequent characters remain unscanned. A series of directives composed of %n, %t, whitespace characters or any combination thereof 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. Any other conversion specification is executed by scanning characters until a character matching the next directive is scanned, or until no more characters can be scanned. These characters, except the one matching the next directive, 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. Case is ignored when matching items in buf such as month or weekday names. If no match is found, strptime() fails and no more characters are scanned. If the date specified exceeds the maximum time representable by the time_t data type in 32-bit HP-UX (which represents Tuesday January 19 03:14:07 UTC, 2038) or if the date exceeds the maximum date supported in 64-bit HP-UX (which is Friday December 31 23:59:59 UTC, 9999), strptime() fails and a null pointer is returned. EXTERNAL INFLUENCESEnvironment VariablesLC_NUMERIC may define the alternative symbols (alt_digit; see localedef(4)) used by the %O modifier. The alt_digit definition has precedence over alt_digits (LC_TIME). Support for alt_digit may be removed in a future release of HP-UX. LC_TIME determines the characters to be interpreted for those directives described above as being from the locale. LC_CTYPE determines the interpretation of the bytes within format as single- and/or multibyte characters. RETURN VALUEUpon successful completion, strptime() returns a pointer to the character following the last character parsed. Otherwise, a null pointer is returned. EXAMPLESThe following program segment uses strptime() to convert the string (first argument) to values according to the format specified in the second argument. struct tm t; setlocale(LC_TIME, "en_US.iso88591"); strptime("1:04:23 PM on 10/6/92", "%I:%M:%S %p on %D", &t); The converted value is stored in the structure t as follows: t.tm_sec = 23 t.tm_min = 4 t.tm_hour = 13 t.tm_mday = 6 t.tm_mon = 9 t.tm_year = 92 t.tm_wday = 2 t.tm_yday = 279 t.tm_isdst = 1 |
Printable version | ||
|