From 85dbf190c69f747cea3f8cdabecb3464ab1351be Mon Sep 17 00:00:00 2001 From: Alexander Shishkin Date: Mon, 22 Mar 2010 18:22:33 +0100 Subject: date,touch: accept Jan 7 00:00:00 2010 format function old new delta parse_datestr 618 647 +29 Signed-off-by: Alexander Shishkin Signed-off-by: Denys Vlasenko --- libbb/time.c | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) (limited to 'libbb/time.c') diff --git a/libbb/time.c b/libbb/time.c index 45ae6f3a7..5cd04268c 100644 --- a/libbb/time.c +++ b/libbb/time.c @@ -15,6 +15,9 @@ void FAST_FUNC parse_datestr(const char *date_str, struct tm *ptm) if (last_colon != NULL) { /* Parse input and assign appropriately to ptm */ +#if ENABLE_DESKTOP + const char *endp; +#endif /* HH:MM */ if (sscanf(date_str, "%u:%u%c", @@ -46,8 +49,17 @@ void FAST_FUNC parse_datestr(const char *date_str, struct tm *ptm) &end) >= 5) { ptm->tm_year -= 1900; /* Adjust years */ ptm->tm_mon -= 1; /* Adjust month from 1-12 to 0-11 */ + } else +#if ENABLE_DESKTOP /* strptime is BIG: ~1k in uclibc, ~10k in glibc */ + /* month_name d HH:MM:SS YYYY. Supported by GNU date */ + if ((endp = strptime(date_str, "%b %d %T %Y", ptm)) != NULL + && *endp == '\0' + ) { + return; /* don't fall through to end == ":" check */ + } else +#endif //TODO: coreutils 6.9 also accepts "yyyy-mm-dd HH" (no minutes) - } else { + { bb_error_msg_and_die(bb_msg_invalid_date, date_str); } if (end == ':') { -- cgit v1.2.3