[git commit master] date: support -d @SECONDS_SINCE_1970

Denys Vlasenko vda.linux at googlemail.com
Thu Apr 22 04:45:28 UTC 2010


commit: http://git.busybox.net/busybox/commit/?id=5f94346f7387cb5e33cf202dd3306f062bb22052
branch: http://git.busybox.net/busybox/commit/?id=refs/heads/master

function                                             old     new   delta
parse_datestr                                        647     721     +74

Signed-off-by: Denys Vlasenko <vda.linux at googlemail.com>
---
 libbb/time.c |   10 ++++++++++
 1 files changed, 10 insertions(+), 0 deletions(-)

diff --git a/libbb/time.c b/libbb/time.c
index 5cd0426..8d176e5 100644
--- a/libbb/time.c
+++ b/libbb/time.c
@@ -68,6 +68,16 @@ void FAST_FUNC parse_datestr(const char *date_str, struct tm *ptm)
 				end = '\0';
 			/* else end != NUL and we error out */
 		}
+	} else if (date_str[0] == '@') {
+		time_t t = bb_strtol(date_str + 1, NULL, 10);
+		if (!errno) {
+			struct tm *lt = localtime(&t);
+			if (lt) {
+				*ptm = *lt;
+				return;
+			}
+		}
+		end = '1';
 	} else {
 		/* Googled the following on an old date manpage:
 		 *
-- 
1.6.3.3



More information about the busybox-cvs mailing list