date: support -d @SECONDS_SINCE_1970
authorDenys Vlasenko <vda.linux@googlemail.com>
Thu, 22 Apr 2010 04:45:28 +0000 (00:45 -0400)
committerDenys Vlasenko <vda.linux@googlemail.com>
Thu, 22 Apr 2010 04:45:28 +0000 (00:45 -0400)
function                                             old     new   delta
parse_datestr                                        647     721     +74

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
libbb/time.c

index 5cd04268cfc45212dad32f951dff492603c82ce5..8d176e52e3a9d1ace0ef784e39ce1b465f264b2b 100644 (file)
@@ -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:
                 *