#include #include #include #include #include int period_helper_parse_hhmm(const char *hhmm_str, uint16_t *hhmm) { if(strlen(hhmm_str) != 5) { return 1; } if(hhmm_str[2] != ':') { return 1; } for(int i = 0; i < 5; ++i) { if(i != 2) { if(hhmm_str[i] < '0' || hhmm_str[i] > '9') { return 1; } } } uint16_t tmp_h, tmp_m; tmp_h = (uint16_t)strtol(&hhmm_str[0], NULL, 10); tmp_m = (uint16_t)strtol(&hhmm_str[3], NULL, 10); *hhmm = (tmp_h * 60) + tmp_m; return 0; }