|
Zbigniew Jędrzejewski-Szmek |
2b6823 |
From 182b69ec5eade7b2accc09d58128b6d286067299 Mon Sep 17 00:00:00 2001
|
|
Zbigniew Jędrzejewski-Szmek |
2b6823 |
From: Hristo Venev <hristo@venev.name>
|
|
Zbigniew Jędrzejewski-Szmek |
2b6823 |
Date: Mon, 22 Feb 2016 08:02:48 -0500
|
|
Zbigniew Jędrzejewski-Szmek |
2b6823 |
Subject: [PATCH] calendarspec: fix find_next skipping times
|
|
Zbigniew Jędrzejewski-Szmek |
2b6823 |
|
|
Zbigniew Jędrzejewski-Szmek |
2b6823 |
reset usec when bumping hours/minutes
|
|
Zbigniew Jędrzejewski-Szmek |
2b6823 |
|
|
Zbigniew Jędrzejewski-Szmek |
2b6823 |
(cherry picked from commit a022d76e6a7c711954be5535e6308d0a470e232a)
|
|
Zbigniew Jędrzejewski-Szmek |
2b6823 |
---
|
|
Zbigniew Jędrzejewski-Szmek |
2b6823 |
src/basic/calendarspec.c | 4 ++--
|
|
Zbigniew Jędrzejewski-Szmek |
2b6823 |
src/test/test-calendarspec.c | 1 +
|
|
Zbigniew Jędrzejewski-Szmek |
2b6823 |
2 files changed, 3 insertions(+), 2 deletions(-)
|
|
Zbigniew Jędrzejewski-Szmek |
2b6823 |
|
|
Zbigniew Jędrzejewski-Szmek |
2b6823 |
diff --git a/src/basic/calendarspec.c b/src/basic/calendarspec.c
|
|
Zbigniew Jędrzejewski-Szmek |
2b6823 |
index 775879076d..ac7b7c4c87 100644
|
|
Zbigniew Jędrzejewski-Szmek |
2b6823 |
--- a/src/basic/calendarspec.c
|
|
Zbigniew Jędrzejewski-Szmek |
2b6823 |
+++ b/src/basic/calendarspec.c
|
|
Zbigniew Jędrzejewski-Szmek |
2b6823 |
@@ -1027,7 +1027,7 @@ static int find_next(const CalendarSpec *spec, struct tm *tm, usec_t *usec) {
|
|
Zbigniew Jędrzejewski-Szmek |
2b6823 |
|
|
Zbigniew Jędrzejewski-Szmek |
2b6823 |
r = find_matching_component(spec->hour, &c.tm_hour);
|
|
Zbigniew Jędrzejewski-Szmek |
2b6823 |
if (r > 0)
|
|
Zbigniew Jędrzejewski-Szmek |
2b6823 |
- c.tm_min = c.tm_sec = 0;
|
|
Zbigniew Jędrzejewski-Szmek |
2b6823 |
+ c.tm_min = c.tm_sec = tm_usec = 0;
|
|
Zbigniew Jędrzejewski-Szmek |
2b6823 |
if (r < 0 || tm_out_of_bounds(&c, spec->utc)) {
|
|
Zbigniew Jędrzejewski-Szmek |
2b6823 |
c.tm_mday ++;
|
|
Zbigniew Jędrzejewski-Szmek |
2b6823 |
c.tm_hour = c.tm_min = c.tm_sec = tm_usec = 0;
|
|
Zbigniew Jędrzejewski-Szmek |
2b6823 |
@@ -1036,7 +1036,7 @@ static int find_next(const CalendarSpec *spec, struct tm *tm, usec_t *usec) {
|
|
Zbigniew Jędrzejewski-Szmek |
2b6823 |
|
|
Zbigniew Jędrzejewski-Szmek |
2b6823 |
r = find_matching_component(spec->minute, &c.tm_min);
|
|
Zbigniew Jędrzejewski-Szmek |
2b6823 |
if (r > 0)
|
|
Zbigniew Jędrzejewski-Szmek |
2b6823 |
- c.tm_sec = 0;
|
|
Zbigniew Jędrzejewski-Szmek |
2b6823 |
+ c.tm_sec = tm_usec = 0;
|
|
Zbigniew Jędrzejewski-Szmek |
2b6823 |
if (r < 0 || tm_out_of_bounds(&c, spec->utc)) {
|
|
Zbigniew Jędrzejewski-Szmek |
2b6823 |
c.tm_hour ++;
|
|
Zbigniew Jędrzejewski-Szmek |
2b6823 |
c.tm_min = c.tm_sec = tm_usec = 0;
|
|
Zbigniew Jędrzejewski-Szmek |
2b6823 |
diff --git a/src/test/test-calendarspec.c b/src/test/test-calendarspec.c
|
|
Zbigniew Jędrzejewski-Szmek |
2b6823 |
index 8754cb3381..5a8c6cbfb6 100644
|
|
Zbigniew Jędrzejewski-Szmek |
2b6823 |
--- a/src/test/test-calendarspec.c
|
|
Zbigniew Jędrzejewski-Szmek |
2b6823 |
+++ b/src/test/test-calendarspec.c
|
|
Zbigniew Jędrzejewski-Szmek |
2b6823 |
@@ -137,6 +137,7 @@ int main(int argc, char* argv[]) {
|
|
Zbigniew Jędrzejewski-Szmek |
2b6823 |
test_next("2015-11-13 09:11:23.42", "EET", 12345, 1447398683420000);
|
|
Zbigniew Jędrzejewski-Szmek |
2b6823 |
test_next("2015-11-13 09:11:23.42/1.77", "EET", 1447398683420000, 1447398685190000);
|
|
Zbigniew Jędrzejewski-Szmek |
2b6823 |
test_next("2015-11-13 09:11:23.42/1.77", "EET", 1447398683419999, 1447398683420000);
|
|
Zbigniew Jędrzejewski-Szmek |
2b6823 |
+ test_next("Sun 16:00:00", "CET", 1456041600123456, 1456066800000000);
|
|
Zbigniew Jędrzejewski-Szmek |
2b6823 |
|
|
Zbigniew Jędrzejewski-Szmek |
2b6823 |
assert_se(calendar_spec_from_string("test", &c) < 0);
|
|
Zbigniew Jędrzejewski-Szmek |
2b6823 |
assert_se(calendar_spec_from_string("", &c) < 0);
|