Skip to content

Commit

Permalink
Merge pull request #2695 from mustrumr/fix-calendarspec-skip
Browse files Browse the repository at this point in the history
calendarspec: fix find_next skipping times
  • Loading branch information
poettering committed Feb 22, 2016
2 parents 83ea204 + a022d76 commit a4ae7f1
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/basic/calendarspec.c
Expand Up @@ -1029,7 +1029,7 @@ static int find_next(const CalendarSpec *spec, struct tm *tm, usec_t *usec) {

r = find_matching_component(spec->hour, &c.tm_hour);
if (r > 0)
c.tm_min = c.tm_sec = 0;
c.tm_min = c.tm_sec = tm_usec = 0;
if (r < 0 || tm_out_of_bounds(&c, spec->utc)) {
c.tm_mday ++;
c.tm_hour = c.tm_min = c.tm_sec = tm_usec = 0;
Expand All @@ -1038,7 +1038,7 @@ static int find_next(const CalendarSpec *spec, struct tm *tm, usec_t *usec) {

r = find_matching_component(spec->minute, &c.tm_min);
if (r > 0)
c.tm_sec = 0;
c.tm_sec = tm_usec = 0;
if (r < 0 || tm_out_of_bounds(&c, spec->utc)) {
c.tm_hour ++;
c.tm_min = c.tm_sec = tm_usec = 0;
Expand Down
1 change: 1 addition & 0 deletions src/test/test-calendarspec.c
Expand Up @@ -137,6 +137,7 @@ int main(int argc, char* argv[]) {
test_next("2015-11-13 09:11:23.42", "EET", 12345, 1447398683420000);
test_next("2015-11-13 09:11:23.42/1.77", "EET", 1447398683420000, 1447398685190000);
test_next("2015-11-13 09:11:23.42/1.77", "EET", 1447398683419999, 1447398683420000);
test_next("Sun 16:00:00", "CET", 1456041600123456, 1456066800000000);

assert_se(calendar_spec_from_string("test", &c) < 0);
assert_se(calendar_spec_from_string("", &c) < 0);
Expand Down

0 comments on commit a4ae7f1

Please sign in to comment.