.\" Copyright 1993 Mitchum DSouza .\" .\" Permission is granted to make and distribute verbatim copies of this .\" manual provided the copyright notice and this permission notice are .\" preserved on all copies. .\" .\" Permission is granted to copy and distribute modified versions of this .\" manual under the conditions for verbatim copying, provided that the .\" entire resulting derived work is distributed under the terms of a .\" permission notice identical to this one .\" .\" Since the Linux kernel and libraries are constantly changing, this .\" manual page may be incorrect or out-of-date. The author(s) assume no .\" responsibility for errors or omissions, or for damages resulting from .\" the use of the information contained herein. The author(s) may not .\" have taken the same level of care in the production of this manual, .\" which is licensed free of charge, as they might when working .\" professionally. .\" .\" Formatted or processed versions of this manual, if unaccompanied by .\" the source, must acknowledge the copyright and authors of this work. .\" .TH STRPTIME 3 "26 September 1994" "GNU" "Linux Programmer's Manual" .SH NAME strptime \- convert a string representation of time to a time tm structure .SH SYNOPSIS .B #include .sp .BI "char *strptime(char *" buf ", const char *" format , .BI "const struct tm *" tm ); .SH DESCRIPTION .LP .IX "strptime function" "" "\fLstrptime()\fP \(em date and time conversion" .B strptime(\|) is the complementary function to .B strftime(\|) and converts the character string pointed to by .I buf to a time value, which is stored in the .B tm structure pointed to by .IR tm , using the format specified by .IR format . .I format is a character string that consists of field descriptors and text characters, reminiscent of .BR scanf (3). Each field descriptor consists of a .B % character followd by another character that specifies the replacement for the field descriptor. All other characters are copied from .I format into the result. The following field descriptors are supported: .RS .TP .B %% same as .B % .TP .B %a .PD 0 .TP .B %A day of week, using locale's weekday names; either the abbreviated or full name may be specified .PD .TP .B %b .PD 0 .TP .B %B .TP .B %h month, using locale's month names; either the abbreviated or full name may be specified .PD .TP .B %c date and time as %x %X .TP .B %C date and time, in locale's long-format date and time representation .TP .B %d .PD 0 .TP .B %e day of month (1-31; leading zeroes are permitted but not required) .PD .TP .B %D date as %m/%d/%y .TP .B %H .PD 0 .TP .B %k hour (0-23; leading zeroes are permitted but not required) .PD .TP .B %I .PD 0 .TP .B %l hour (0-12; leading zeroes are permitted but not required) .PD .TP .B %j day number of year (001-366) .TP .B %m month number (1-12; leading zeroes are permitted but not required) .TP .B %M minute (0-59; leading zeroes are permitted but not required) .TP .B %p locale's equivalent of .SM AM or .SM PM .TP .B %r time as %I:%M:%S %p .TP .B %R time as %H:%M .TP .B %S seconds (0-61; leading zeroes are permitted but not required. Extra second allowed for leap years) .TP .B %T time as %H:%M:%S .TP .B %w weekday number (0-6) with Sunday as the first day of the week .TP .B %x date, using locale's date format .TP .B %X time, using locale's time format .TP .B %y year within century (0-99; leading zeroes are permitted but not required. Unfortunately this makes the assumption that we are stuck in the 20th century as 1900 is automatically added onto this number for the tm_year field) .TP .B %Y year, including century (for example, 1988) .RE .LP Case is ignored when matching items such as month or weekday names. .LP The broken-down time structure \fItm\fP is defined in \fI\fP as follows: .sp .RS .nf .ne 12 .ta 8n 16n 32n 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 */ }; .ta .fi .RE .SH "RETURN VALUE" The \fBstrptime()\fP function returns a pointer to the character following the last character in the string pointed to by .I buf \. .SH "SEE ALSO" .BR strftime "(3), " time "(2), " setlocale "(3), " scanf (3) .SH BUGS .LP The return values point to static data, whose contents are overwritten by each call. .SH NOTES .LP This function is only available in libraries newer than version 4.6.5 .PP The function supports only those locales specified in .BR locale "(7)"