diff options
author | Alexander Shishkin <virtuoso@slind.org> | 2010-03-22 18:22:33 +0100 |
---|---|---|
committer | Denys Vlasenko <vda.linux@googlemail.com> | 2010-03-22 18:22:33 +0100 |
commit | 85dbf190c69f747cea3f8cdabecb3464ab1351be (patch) | |
tree | c6d6542635e4d2b95f7b8637bbca905e391617cb | |
parent | 6b61629397e121de9e879ed31b9309e56f9286bc (diff) | |
download | busybox-w32-85dbf190c69f747cea3f8cdabecb3464ab1351be.tar.gz busybox-w32-85dbf190c69f747cea3f8cdabecb3464ab1351be.tar.bz2 busybox-w32-85dbf190c69f747cea3f8cdabecb3464ab1351be.zip |
date,touch: accept Jan 7 00:00:00 2010 format
function old new delta
parse_datestr 618 647 +29
Signed-off-by: Alexander Shishkin <virtuoso@slind.org>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
-rw-r--r-- | libbb/time.c | 14 |
1 files changed, 13 insertions, 1 deletions
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) | |||
15 | 15 | ||
16 | if (last_colon != NULL) { | 16 | if (last_colon != NULL) { |
17 | /* Parse input and assign appropriately to ptm */ | 17 | /* Parse input and assign appropriately to ptm */ |
18 | #if ENABLE_DESKTOP | ||
19 | const char *endp; | ||
20 | #endif | ||
18 | 21 | ||
19 | /* HH:MM */ | 22 | /* HH:MM */ |
20 | if (sscanf(date_str, "%u:%u%c", | 23 | if (sscanf(date_str, "%u:%u%c", |
@@ -46,8 +49,17 @@ void FAST_FUNC parse_datestr(const char *date_str, struct tm *ptm) | |||
46 | &end) >= 5) { | 49 | &end) >= 5) { |
47 | ptm->tm_year -= 1900; /* Adjust years */ | 50 | ptm->tm_year -= 1900; /* Adjust years */ |
48 | ptm->tm_mon -= 1; /* Adjust month from 1-12 to 0-11 */ | 51 | ptm->tm_mon -= 1; /* Adjust month from 1-12 to 0-11 */ |
52 | } else | ||
53 | #if ENABLE_DESKTOP /* strptime is BIG: ~1k in uclibc, ~10k in glibc */ | ||
54 | /* month_name d HH:MM:SS YYYY. Supported by GNU date */ | ||
55 | if ((endp = strptime(date_str, "%b %d %T %Y", ptm)) != NULL | ||
56 | && *endp == '\0' | ||
57 | ) { | ||
58 | return; /* don't fall through to end == ":" check */ | ||
59 | } else | ||
60 | #endif | ||
49 | //TODO: coreutils 6.9 also accepts "yyyy-mm-dd HH" (no minutes) | 61 | //TODO: coreutils 6.9 also accepts "yyyy-mm-dd HH" (no minutes) |
50 | } else { | 62 | { |
51 | bb_error_msg_and_die(bb_msg_invalid_date, date_str); | 63 | bb_error_msg_and_die(bb_msg_invalid_date, date_str); |
52 | } | 64 | } |
53 | if (end == ':') { | 65 | if (end == ':') { |