"%b %d %T %Y" is actually supported by the GNU date and there are scripts
out there using it:

$ date -d "Jan 7 00:00:00 2010"
Thu Jan  7 00:00:00 UTC 2010

function                                             old     new   delta
parse_datestr                                        638     668     +30
.rodata                                            42318   42330     +12
------------------------------------------------------------------------------
(add/remove: 0/0 grow/shrink: 2/0 up/down: 42/0)               Total: 42 bytes

Signed-off-by: Alexander Shishkin <[email protected]>
---
 libbb/time.c |    5 +++++
 1 files changed, 5 insertions(+), 0 deletions(-)

diff --git a/libbb/time.c b/libbb/time.c
index 45ae6f3..beeb4dc 100644
--- a/libbb/time.c
+++ b/libbb/time.c
@@ -46,6 +46,11 @@ 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
+               /* month_name d HH:MM:SS
+                * this is supported by the GNU make */
+               if (isalpha(date_str[0])) {
+                       strptime(date_str, "%b %d %T %Y", ptm);
 //TODO: coreutils 6.9 also accepts "yyyy-mm-dd HH" (no minutes)
                } else {
                        bb_error_msg_and_die(bb_msg_invalid_date, date_str);
-- 
1.6.3.3

_______________________________________________
busybox mailing list
[email protected]
http://lists.busybox.net/mailman/listinfo/busybox

Reply via email to