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)
{
while(weekdaysInt > 0)
{
if(weekdaysInt >= 64)
if ((weekdaysInt & 0b01000000) > 0)
{
weekdays.add("mon");
weekdaysInt -= 64;
continue;
}
if(weekdaysInt >= 32)
if ((weekdaysInt & 0b00100000) > 0)
{
weekdays.add("tue");
weekdaysInt -= 32;
continue;
}
if(weekdaysInt >= 16)
if ((weekdaysInt & 0b00010000) > 0)
{
weekdays.add("wed");
weekdaysInt -= 16;
continue;
}
if(weekdaysInt >= 8)
if ((weekdaysInt & 0b00001000) > 0)
{
weekdays.add("thu");
weekdaysInt -= 8;
continue;
}
if(weekdaysInt >= 4)
if ((weekdaysInt & 0b00000100) > 0)
{
weekdays.add("fri");
weekdaysInt -= 4;
continue;
}
if(weekdaysInt >= 2)
if ((weekdaysInt & 0b00000010) > 0)
{
weekdays.add("sat");
weekdaysInt -= 2;
continue;
}
if(weekdaysInt >= 1)
if ((weekdaysInt & 0b00000001) > 0)
{
weekdays.add("sun");
weekdaysInt -= 1;
}
}
}