core/clock/zone_setting.c
| Line | Branch | Exec | Source |
|---|---|---|---|
| 1 | /** | ||
| 2 | * @file zone_setting.c | ||
| 3 | * @brief Reads a time zone setting the way the phone sends it. | ||
| 4 | * | ||
| 5 | * @ingroup lib_core | ||
| 6 | */ | ||
| 7 | #include "clock/zone_setting.h" | ||
| 8 | |||
| 9 | #include <stdlib.h> | ||
| 10 | #include <string.h> | ||
| 11 | |||
| 12 | 5 | bool zone_setting_is_set(const char *value) | |
| 13 | { | ||
| 14 |
4/4✓ Branch 0 taken 4 times.
✓ Branch 1 taken 1 time.
✓ Branch 2 taken 3 times.
✓ Branch 3 taken 1 time.
|
5 | return value && value[0] != '\0'; |
| 15 | } | ||
| 16 | |||
| 17 | 2 | int16_t zone_setting_offset(const char *value) | |
| 18 | { | ||
| 19 | // atoi stops at the comma, so it reads the minutes and nothing after them | ||
| 20 |
1/2✓ Branch 1 taken 2 times.
✗ Branch 2 not taken.
|
2 | return zone_setting_is_set(value) ? (int16_t)atoi(value) : 0; |
| 21 | } | ||
| 22 | |||
| 23 | 2 | const char *zone_setting_label(const char *value) | |
| 24 | { | ||
| 25 |
1/2✓ Branch 0 taken 2 times.
✗ Branch 1 not taken.
|
2 | const char *comma = value ? strchr(value, ',') : NULL; |
| 26 |
2/2✓ Branch 0 taken 1 time.
✓ Branch 1 taken 1 time.
|
2 | return comma ? comma + 1 : ""; |
| 27 | } | ||
| 28 |