diff --git a/newlib/libc/time/strptime.c b/newlib/libc/time/strptime.c index c0861eb87..b352bcbab 100644 --- a/newlib/libc/time/strptime.c +++ b/newlib/libc/time/strptime.c @@ -38,6 +38,7 @@ #include #include #include +#include #include "../locale/setlocale.h" #define _ctloc(x) (_CurrentTimeLocale->x) @@ -230,6 +231,13 @@ strptime_l (const char *buf, const char *format, struct tm *timeptr, buf = s; ymd |= SET_MDAY; break; + case 'F' : /* %Y-%m-%d */ + s = strptime_l (buf, "%Y-%m-%d", timeptr, locale); + if (s == NULL) + return NULL; + buf = s; + ymd |= SET_YMD; + break; case 'H' : case 'k' : ret = strtol_l (buf, &s, 10, locale); @@ -300,6 +308,21 @@ strptime_l (const char *buf, const char *format, struct tm *timeptr, return NULL; buf = s; break; + case 's' : { + intmax_t sec; + time_t t; + + sec = strtoimax (buf, &s, 10); + t = (time_t)sec; + if (s == buf + || (intmax_t)t != sec + || localtime_r (&t, timeptr) != timeptr) + return NULL; + ; + buf = s; + ymd |= SET_YDAY | SET_WDAY | SET_YMD; + break; + } case 'S' : ret = strtol_l (buf, &s, 10, locale); if (s == buf)