simplify code to calculate weekday text

This commit is contained in:
technyon
2025-10-06 20:16:51 +07:00
parent b6e6b4400c
commit 177a0c4441

View File

@@ -448,49 +448,33 @@ void NukiHelper::fobActionToString(const int fobact, char* str)
void NukiHelper::weekdaysToJsonArray(int weekdaysInt, JsonArray& weekdays) void NukiHelper::weekdaysToJsonArray(int weekdaysInt, JsonArray& weekdays)
{ {
while(weekdaysInt > 0) if ((weekdaysInt & 0b01000000) > 0)
{ {
if(weekdaysInt >= 64) weekdays.add("mon");
{ }
weekdays.add("mon"); if ((weekdaysInt & 0b00100000) > 0)
weekdaysInt -= 64; {
continue; weekdays.add("tue");
} }
if(weekdaysInt >= 32) if ((weekdaysInt & 0b00010000) > 0)
{ {
weekdays.add("tue"); weekdays.add("wed");
weekdaysInt -= 32; }
continue; if ((weekdaysInt & 0b00001000) > 0)
} {
if(weekdaysInt >= 16) weekdays.add("thu");
{ }
weekdays.add("wed"); if ((weekdaysInt & 0b00000100) > 0)
weekdaysInt -= 16; {
continue; weekdays.add("fri");
} }
if(weekdaysInt >= 8) if ((weekdaysInt & 0b00000010) > 0)
{ {
weekdays.add("thu"); weekdays.add("sat");
weekdaysInt -= 8; }
continue; if ((weekdaysInt & 0b00000001) > 0)
} {
if(weekdaysInt >= 4) weekdays.add("sun");
{
weekdays.add("fri");
weekdaysInt -= 4;
continue;
}
if(weekdaysInt >= 2)
{
weekdays.add("sat");
weekdaysInt -= 2;
continue;
}
if(weekdaysInt >= 1)
{
weekdays.add("sun");
weekdaysInt -= 1;
}
} }
} }