| 447 | } |
| 448 | |
| 449 | static u64 time_change(u64 prevstart, u32 number, |
| 450 | void (*add_time)(struct tm *tm, u32 number), |
| 451 | bool day_const) |
| 452 | { |
| 453 | struct tm tm; |
| 454 | time_t prev = prevstart, ret; |
| 455 | |
| 456 | tm = *gmtime(&prev); |
| 457 | |
| 458 | for (;;) { |
| 459 | struct tm new_tm = tm; |
| 460 | add_time(&new_tm, number); |
| 461 | ret = mktime(&new_tm); |
| 462 | |
| 463 | if (ret == (time_t)-1) |
| 464 | return 0; |
| 465 | |
| 466 | /* If we overflowed that month, try one less. */ |
| 467 | if (!day_const || new_tm.tm_mday == tm.tm_mday) |
| 468 | break; |
| 469 | tm.tm_mday--; |
| 470 | } |
| 471 | |
| 472 | return ret; |
| 473 | } |
| 474 | |
| 475 | u64 offer_period_start(u64 basetime, size_t n, |
| 476 | const struct recurrence *recur) |
no outgoing calls
no test coverage detected