diff options
author | Elliott Hughes <enh@google.com> | 2021-06-01 15:59:08 -0700 |
---|---|---|
committer | Rob Landley <rob@landley.net> | 2021-06-02 04:32:01 -0500 |
commit | b93f5908e2f0932620e5120fb52a942fa5573cf9 (patch) | |
tree | 2a69d3c9c5f2eaf5bd19331b19dba8d6411e343e /toys | |
parent | c7e261720f3f5295dcb4e2f07d2e5fcb93bb9ce6 (diff) | |
download | toybox-b93f5908e2f0932620e5120fb52a942fa5573cf9.tar.gz |
date: add -s.
Used by someone's script.
Diffstat (limited to 'toys')
-rw-r--r-- | toys/posix/date.c | 10 |
1 files changed, 8 insertions, 2 deletions
diff --git a/toys/posix/date.c b/toys/posix/date.c index 86c2d343..99a41695 100644 --- a/toys/posix/date.c +++ b/toys/posix/date.c @@ -7,7 +7,7 @@ * Note: setting a 2 year date is 50 years back/forward from today, * not posix's hardwired magic dates. -USE_DATE(NEWTOY(date, "d:D:I(iso)(iso-8601):;r:u(utc)[!dr]", TOYFLAG_BIN)) +USE_DATE(NEWTOY(date, "d:D:I(iso)(iso-8601):;r:s:u(utc)[!dr]", TOYFLAG_BIN)) config DATE bool "date" @@ -21,6 +21,7 @@ config DATE -D +FORMAT for SET or -d (instead of MMDDhhmm[[CC]YY][.ss]) -I RES ISO 8601 with RESolution d=date/h=hours/m=minutes/s=seconds/n=ns -r Use modification time of FILE instead of current date + -s DATE Set the system clock to DATE. -u Use UTC instead of current timezone Supported input formats: @@ -59,7 +60,7 @@ config DATE #include "toys.h" GLOBALS( - char *r, *I, *D, *d; + char *s, *r, *I, *D, *d; unsigned nano; ) @@ -170,6 +171,11 @@ void date_main(void) TT.nano = ts.tv_nsec; } + if (FLAG(s)) { + if (setdate) help_exit("can't set two dates at once"); + setdate = TT.s; + } + // Fall through if no arguments if (!setdate); // Display the date? |