lineedit: do not hang on error, but return error indicator.
[oweals/busybox.git] / libbb / time.c
index 5cd04268cfc45212dad32f951dff492603c82ce5..2a74d34c2c435299f59f845e72ca29f098c125d8 100644 (file)
@@ -4,7 +4,7 @@
  *
  * Copyright (C) 2007 Denys Vlasenko
  *
- * Licensed under GPL version 2, see file LICENSE in this tarball for details.
+ * Licensed under GPLv2, see file LICENSE in this source tree.
  */
 #include "libbb.h"
 
@@ -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:
                 *