calendarspec: parse unix timestamps (@...) (#5947)

Fixes #5810.
This commit is contained in:
Zbigniew Jędrzejewski-Szmek
2017-05-17 11:40:49 +02:00
committed by Lennart Poettering
parent a8b7e8a742
commit d80e5b74e8
3 changed files with 93 additions and 13 deletions
+5
View File
@@ -193,6 +193,11 @@ int main(int argc, char* argv[]) {
test_one("*:20..39/5", "*-*-* *:20..35/5:00");
test_one("00:00:20..40/1", "*-*-* 00:00:20..40");
test_one("*~03/1,03..05", "*-*~03/1,03..05 00:00:00");
/* UNIX timestamps are always UTC */
test_one("@1493187147", "2017-04-26 06:12:27 UTC");
test_one("@1493187147 UTC", "2017-04-26 06:12:27 UTC");
test_one("@0", "1970-01-01 00:00:00 UTC");
test_one("@0 UTC", "1970-01-01 00:00:00 UTC");
test_next("2016-03-27 03:17:00", "", 12345, 1459048620000000);
test_next("2016-03-27 03:17:00", "CET", 12345, 1459041420000000);
+1 -1
View File
@@ -29,7 +29,7 @@ static void test_should_pass(const char *p) {
assert_se(parse_timestamp(p, &t) >= 0);
format_timestamp_us(buf, sizeof(buf), t);
log_info("%s", buf);
log_info("\"%s\" → \"%s\"", p, buf);
/* Chop off timezone */
sp = strrchr(buf, ' ');