summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorLennart Poettering <lennart@poettering.net>2014-03-25 04:08:16 +0100
committerLennart Poettering <lennart@poettering.net>2014-03-25 04:08:16 +0100
commit5ba6e0949cef1a5b947dd59665bad1ca5066619d (patch)
tree8ebd76a03be18a8c45640e8b66e4e01fdf57d021 /src
parenta2b135e3d8d5dfa103a87e304ed8a91b01fdbb02 (diff)
time: support @ syntax for denoting times since the UNIX epoch 1970-1-1
Diffstat (limited to 'src')
-rw-r--r--src/shared/calendarspec.c1
-rw-r--r--src/shared/time-util.c9
-rw-r--r--src/test/test-date.c1
3 files changed, 7 insertions, 4 deletions
diff --git a/src/shared/calendarspec.c b/src/shared/calendarspec.c
index 7075159183..69b7427232 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 faa3418819..eb5c1ae790 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);
diff --git a/src/test/test-date.c b/src/test/test-date.c
index 40ffc17b2f..0586b78b6d 100644
--- a/src/test/test-date.c
+++ b/src/test/test-date.c
@@ -56,6 +56,7 @@ int main(int argc, char *argv[]) {
test_one("+2d");
test_one("+2y 4d");
test_one("5months ago");
+ test_one("@1395716396");
return 0;
}