diff options
author | Sami Kerola | 2015-01-10 19:31:29 +0100 |
---|---|---|
committer | Karel Zak | 2015-06-29 13:39:37 +0200 |
commit | a10ce9a3e5090f9eab0b34618280d7177568d884 (patch) | |
tree | a2334fbbbfa3265d6eb98a1b937528add36502ee /sys-utils | |
parent | rtcwake: improve read_clock_mode() (diff) | |
download | kernel-qcow2-util-linux-a10ce9a3e5090f9eab0b34618280d7177568d884.tar.gz kernel-qcow2-util-linux-a10ce9a3e5090f9eab0b34618280d7177568d884.tar.xz kernel-qcow2-util-linux-a10ce9a3e5090f9eab0b34618280d7177568d884.zip |
rtcwake: add human readable --date timestamp format
Reviewed-by: Benno Schulenberg <bensberg@justemail.net>
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
Diffstat (limited to 'sys-utils')
-rw-r--r-- | sys-utils/rtcwake.8.in | 18 | ||||
-rw-r--r-- | sys-utils/rtcwake.c | 24 |
2 files changed, 36 insertions, 6 deletions
diff --git a/sys-utils/rtcwake.8.in b/sys-utils/rtcwake.8.in index 5ec9c6ccb..be4a88f4d 100644 --- a/sys-utils/rtcwake.8.in +++ b/sys-utils/rtcwake.8.in @@ -53,6 +53,22 @@ from the \fIadjtime\fP file, where .BR hwclock (8) stores that information. This is the default. .TP +.BR \-\-date " \fItimestamp" +Set the wakeup time to the value of the timestamp. Format of the +timestmap can be any of the following: +.TS +tab(|); +left l2 l. +YYYYMMDDhhmmss +YYYY-MM-DD hh:mm:ss +YYYY-MM-DD hh:mm|(seconds will be set to 00) +YYYY-MM-DD|(time will be set to 00:00:00) +hh:mm:ss|(date will be set to today) +hh:mm|(date will be set to today, seconds to 00) +tomorrow|(time is set to 00:00:00) ++5min +.TE +.TP .BR \-d , " \-\-device " \fIdevice Use the specified \fIdevice\fP instead of \fBrtc0\fP as realtime clock. This option is only relevant if your system has more than one RTC. @@ -156,4 +172,4 @@ There is NO WARRANTY, to the extent permitted by law. The rtcwake command is part of the util-linux package and is available from the .UR ftp://\:ftp.kernel.org\:/pub\:/linux\:/utils\:/util-linux/ Linux Kernel Archive -.UE .
\ No newline at end of file +.UE . diff --git a/sys-utils/rtcwake.c b/sys-utils/rtcwake.c index 6d67fc26a..0caab24da 100644 --- a/sys-utils/rtcwake.c +++ b/sys-utils/rtcwake.c @@ -41,6 +41,7 @@ #include "strutils.h" #include "c.h" #include "closestream.h" +#include "timeutils.h" /* constants from legacy PC/AT hardware */ #define RTC_PF 0x40 @@ -113,6 +114,7 @@ static void __attribute__((__noreturn__)) usage(FILE *out) fprintf(out, _(" -A, --adjfile <file> specifies the path to the adjust file\n" " the default is %s\n"), _PATH_ADJTIME); + fputs(_(" --date <timestamp> date time of timestamp to wake\n"), out); fputs(_(" -d, --device <device> select rtc device (rtc0|rtc1|...)\n"), out); fputs(_(" -n, --dry-run does everything, but suspend\n"), out); fputs(_(" -l, --local RTC uses local timezone\n"), out); @@ -398,6 +400,10 @@ int main(int argc, char **argv) int fd; time_t alarm = 0; + enum { + OPT_DATE = CHAR_MAX + 1 + }; + static const struct option long_options[] = { {"adjfile", required_argument, 0, 'A'}, {"auto", no_argument, 0, 'a'}, @@ -411,6 +417,7 @@ int main(int argc, char **argv) {"device", required_argument, 0, 'd'}, {"seconds", required_argument, 0, 's'}, {"time", required_argument, 0, 't'}, + {"date", required_argument, 0, OPT_DATE}, {0, 0, 0, 0 } }; @@ -448,18 +455,25 @@ int main(int argc, char **argv) ctl.dryrun = 1; break; - /* alarm time, seconds-to-sleep (relative) */ case 's': + /* alarm time, seconds-to-sleep (relative) */ seconds = strtou32_or_err(optarg, _("invalid seconds argument")); break; - /* alarm time, time_t (absolute, seconds since - * 1/1 1970 UTC) - */ case 't': + /* alarm time, time_t (absolute, seconds since epoc) */ alarm = strtou32_or_err(optarg, _("invalid time argument")); break; + case OPT_DATE: + { + /* alarm time, see timestamp format from manual */ + usec_t p; + if (parse_timestamp(optarg, &p) < 0) + errx(EXIT_FAILURE, _("invalid time value \"%s\""), optarg); + alarm = (time_t) (p / 1000000); + break; + } case 'u': ctl.clock_mode = CM_UTC; break; @@ -491,7 +505,7 @@ int main(int argc, char **argv) _("Using local time.\n")); if (!alarm && !seconds && suspend != DISABLE_MODE && suspend != SHOW_MODE) { - warnx(_("must provide wake time (see -t and -s options)")); + warnx(_("must provide wake time (see --seconds, --time, and --date options)")); usage(stderr); } |