fix determination of the current weekday. (#17812)

the result of c logical expressions is 0 or 1, not the values of the
operands.
This commit is contained in:
David Gwynne 2023-01-29 16:58:20 +10:00 committed by GitHub
parent 78fe958d89
commit 9e522e8fa3
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 6 additions and 1 deletions

View File

@ -862,6 +862,11 @@ tuyamcubr_recv_time(struct tuyamcubr_softc *sc, uint8_t v,
const uint8_t *data, size_t datalen)
{
struct tuyamcubr_time tm;
uint8_t weekday;
weekday = RtcTime.day_of_week - 1;
if (weekday == 0)
weekday = 7;
/* check datalen? should be 0 */
@ -872,7 +877,7 @@ tuyamcubr_recv_time(struct tuyamcubr_softc *sc, uint8_t v,
tm.hour = RtcTime.hour;
tm.minute = RtcTime.minute;
tm.second = RtcTime.second;
tm.weekday = (RtcTime.day_of_week - 1) || 7;
tm.weekday = weekday;
tuyamcubr_send(sc, TUYAMCUBR_CMD_TIME, &tm, sizeof(tm));
}