From 5ba6e0949cef1a5b947dd59665bad1ca5066619d Mon Sep 17 00:00:00 2001 From: Lennart Poettering Date: Tue, 25 Mar 2014 04:08:16 +0100 Subject: time: support @ syntax for denoting times since the UNIX epoch 1970-1-1 --- src/shared/calendarspec.c | 1 - src/shared/time-util.c | 9 ++++++--- 2 files changed, 6 insertions(+), 4 deletions(-) (limited to 'src/shared') diff --git a/src/shared/calendarspec.c b/src/shared/calendarspec.c index 707515918..69b742723 100644 --- a/src/shared/calendarspec.c +++ b/src/shared/calendarspec.c @@ -938,7 +938,6 @@ int calendar_spec_next_usec(const CalendarSpec *spec, usec_t usec, usec_t *next) if (t == (time_t) -1) return -EINVAL; - *next = (usec_t) t * USEC_PER_SEC; return 0; } diff --git a/src/shared/time-util.c b/src/shared/time-util.c index faa341881..eb5c1ae79 100644 --- a/src/shared/time-util.c +++ b/src/shared/time-util.c @@ -432,6 +432,7 @@ int parse_timestamp(const char *t, usec_t *usec) { * tomorrow (time is set to 00:00:00) * +5min * -5days + * @2147483647 (seconds since epoch) * */ @@ -460,21 +461,23 @@ int parse_timestamp(const char *t, usec_t *usec) { goto finish; } else if (t[0] == '+') { - r = parse_sec(t+1, &plus); if (r < 0) return r; goto finish; - } else if (t[0] == '-') { + } else if (t[0] == '-') { r = parse_sec(t+1, &minus); if (r < 0) return r; goto finish; - } else if (endswith(t, " ago")) { + } else if (t[0] == '@') + return parse_sec(t + 1, usec); + + else if (endswith(t, " ago")) { _cleanup_free_ char *z; z = strndup(t, strlen(t) - 4); -- cgit v1.2.3