Used by someone's script.
---
toys/posix/date.c | 10 ++++++++--
1 file changed, 8 insertions(+), 2 deletions(-)
From 6ab306cdfa4763d41e5dcb366063e5de7dc59014 Mon Sep 17 00:00:00 2001
From: Elliott Hughes <[email protected]>
Date: Tue, 1 Jun 2021 15:59:08 -0700
Subject: [PATCH] date: add -s.
Used by someone's script.
---
toys/posix/date.c | 10 ++++++++--
1 file 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?
--
2.32.0.rc0.204.g9fa02ecfa5-goog
_______________________________________________
Toybox mailing list
[email protected]
http://lists.landley.net/listinfo.cgi/toybox-landley.net