core/weather/forecast_age.c
| Line | Branch | Exec | Source |
|---|---|---|---|
| 1 | /** | ||
| 2 | * @file forecast_age.c | ||
| 3 | * @brief How much of a forecast strip has already gone by. | ||
| 4 | * | ||
| 5 | * @ingroup lib_core | ||
| 6 | */ | ||
| 7 | #include "weather/forecast_age.h" | ||
| 8 | |||
| 9 | #define SECONDS_PER_STRIP_HOUR 3600 ///< Seconds in one hour of a forecast strip | ||
| 10 | |||
| 11 | 5 | uint8_t forecast_hours_past(int32_t seconds_into_strip, uint8_t step_hours, uint8_t count) | |
| 12 | { | ||
| 13 |
3/4✓ Branch 0 taken 4 times.
✓ Branch 1 taken 1 time.
✗ Branch 2 not taken.
✓ Branch 3 taken 4 times.
|
5 | if (seconds_into_strip <= 0 || step_hours == 0) |
| 14 | { | ||
| 15 | 1 | return 0; | |
| 16 | } | ||
| 17 | |||
| 18 | 4 | int32_t over = seconds_into_strip / ((int32_t)step_hours * SECONDS_PER_STRIP_HOUR); | |
| 19 |
2/2✓ Branch 0 taken 3 times.
✓ Branch 1 taken 1 time.
|
4 | return over < count ? (uint8_t)over : count; |
| 20 | } | ||
| 21 | |||
| 22 | 4 | uint8_t forecast_days_past(int days_since_first, uint8_t count) | |
| 23 | { | ||
| 24 |
2/2✓ Branch 0 taken 2 times.
✓ Branch 1 taken 2 times.
|
4 | if (days_since_first <= 0) |
| 25 | { | ||
| 26 | 2 | return 0; | |
| 27 | } | ||
| 28 |
2/2✓ Branch 0 taken 1 time.
✓ Branch 1 taken 1 time.
|
2 | return days_since_first < count ? (uint8_t)days_since_first : count; |
| 29 | } | ||
| 30 |