Since the seconds since the Epoch is just a number it might be better to
require special prefix to indicate the intention that the user wants to
interpret the number as seconds since the Epoch.
Use the same '@' character as prefix as used by systemd.time to make it
easier to integrate in scripts intended to be used on systems with or
without systemd.
Fix also the initial support which discarded the seconds from the converted
timestamp.
Signed-off-by: Peter Ujfalusi <peter.ujfalusi@linux.intel.com>
*
* 2012-09-22 16:34:22
* 2012-09-22T16:34:22
- * 1348331662 (seconds since the Epoch (1970-01-01 00:00 UTC))
+ * @1348331662 (seconds since the Epoch (1970-01-01 00:00 UTC))
* 2012-09-22 16:34 (seconds will be set to 0)
* 2012-09-22 (time will be set to 00:00:00)
* 16:34:22 (date will be set to today)
return r;
goto finish;
+ } else if (t[0] == '@') {
+ k = strptime(t + 1, "%s", &tm);
+ if (k && *k == 0)
+ goto finish;
+ return -EINVAL;
} else if (endswith(t, " ago")) {
char *z;
goto finish;
}
- tm = copy;
- k = strptime(t, "%s", &tm);
- if (k && *k == 0) {
- tm.tm_sec = 0;
- goto finish;
- }
-
return -EINVAL;
finish: