Describe the Bug
The string offset for checking the month in convert_timestamp is looking at the 2nd character of the month, instead of the 3rd, for both A and M:
|
rtc_time_t convert_timestamp(const char *timestamp) { |
|
rtc_time_t t; |
|
// Jan Feb Mar Apr May Jun Jul Aug Sep Oct Nov Dec |
|
switch (timestamp[4]) { |
|
case 'J': |
|
t.month = (timestamp[5] == 'a') ? 1 : ((timestamp[6] == 'n') ? 6 : 7); |
|
break; |
|
case 'F': |
|
t.month = 2; |
|
break; |
|
case 'A': |
|
t.month = timestamp[5] == 'r' ? 4 : 8; |
|
break; |
|
case 'M': |
|
t.month = timestamp[5] == 'r' ? 3 : 5; |
This results in incorrect values being returned for Mar or Apr
Can the offset be changed to address this? Alternatively, perhaps helper to parse the month?
// Helper function to parse month abbreviation (e.g. "Jan", "Feb", ...)
static uint8_t parse_month(const char *str) {
static const char *months[] = {
"Jan", "Feb", "Mar", "Apr", "May", "Jun",
"Jul", "Aug", "Sep", "Oct", "Nov", "Dec"
};
for (uint8_t i = 0; i < 12; ++i) {
if (strncmp(str, months[i], 3) == 0) {
return i + 1;
}
}
return 0; // Invalid month
}
// Replace the switch block with:
t.month = parse_month(×tamp[4]);
Additional Context?
No response
Describe the Bug
The string offset for checking the month in
convert_timestampis looking at the 2nd character of the month, instead of the 3rd, for bothAandM:qmk_modules/rtc/rtc.c
Lines 160 to 174 in 218388e
This results in incorrect values being returned for
MarorAprCan the offset be changed to address this? Alternatively, perhaps helper to parse the month?
Additional Context?
No response