Home
Main website
Display Sidebar
Hide Ads
Recent Changes
View Source:
strptime(3)
Edit
PageHistory
Diff
Info
LikePages
STRPTIME !!!STRPTIME NAME SYNOPSIS DESCRIPTION RETURN VALUE NOTES SEE ALSO ---- !!NAME strptime - convert a string representation of time to a time tm structure !!SYNOPSIS __#define _XOPEN_SOURCE__ /* glibc2 needs this */__ #include __char *strptime(const char *__''s''__, const char *__''format''__, struct tm *__''tm''__);__ !!DESCRIPTION __strptime()__ 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: __%%__ the __%__ character __%a__ or __%A__ day of week, using locale's weekday names; either the abbreviated or full name may be specified __%b__ or __%B__ or __%h__ month, using locale's month names; either the abbreviated or full name may be specified __%c__ date and time as %x %X __%C__ date and time, in locale's long-format date and time representation __%d__ or __%e__ day of month (1-31; leading zeroes are permitted but not required) __%D__ date as %m/%d/%y __%H__ or __%k__ hour (0-23; leading zeroes are permitted but not required) __%I__ or __%l__ hour (0-12; leading zeroes are permitted but not required) __%j__ day number of year (001-366) __%m__ month number (1-12; leading zeroes are permitted but not required) __%M__ minute (0-59; leading zeroes are permitted but not required) __%p__ locale's equivalent of AM or PM __%r__ time as %I:%M:%S %p __%R__ time as %H:%M __%S__ seconds (0-61; leading zeroes are permitted but not required. Extra second allowed for leap years) __%T__ time as %H:%M:%S __%w__ weekday number (0-6) with Sunday as the first day of the week __%x__ date, using locale's date format __%X__ time, using locale's time format __%y__ year within century (0-99; leading zeroes are permitted but not required. 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). __%Y__ year, including century (for example, 1988) 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: __%Ec__ the locale's alternative date and time representation. __%EC__ the name of the base year (period) in the locale's alternative representation. __%Ex__ the locale's alternative date representation. __%EX__ the locale's alternative time representation. __%Ey__ the offset from %EC (year only) in the locale's alternative representation. __%EY__ the full alternative year representation. The O modifier specifies that the numerical input may be in an alternative locale-dependent format: __%Od__ or __%Oe__ the day of the month using the locale's alternative numeric symbols; leading zeros are permitted but not required. __%OH__ the hour (24-hour clock) using the locale's alternative numeric symbols. __%OI__ the hour (12-hour clock) using the locale's alternative numeric symbols. __%Om__ the month using the locale's alternative numeric symbols. __%OM__ the minutes using the locale's alternative numeric symbols. __%OS__ the seconds using the locale's alternative numeric symbols. __%OU__ the week number of the year (Sunday as the first day of the week) using the locale's alternative numeric symbols. __%Ow__ the number of the weekday (Sunday=0) using the locale's alternative numeric symbols. __%OW__ the week number of the year (Monday as the first day of the week) using the locale's alternative numeric symbols. __%Oy__ the year (offset from %C) using the locale's alternative numeric symbols. The broken-down time structure ''tm'' is defined in '''' as follows: struct tm { int tm_sec; /* seconds */ int tm_min; /* minutes */ int tm_hour; /* hours */ int tm_mday; /* day of the month */ int tm_mon; /* month */ int tm_year; /* year */ int tm_wday; /* day of the week */ int tm_yday; /* day in the year */ int tm_isdst; /* daylight saving time */ }; !!RETURN VALUE The 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__. !!NOTES In 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 ALSO time(2), scanf(3), setlocale(3), strftime(3) ----
One page links to
strptime(3)
:
Man3s
This page is a man page (or other imported legacy content). We are unable to automatically determine the license status of this page.