Another dumb Lua/Luup question - sorry!

I need to check the day in some scene Lua/Luup code but the following does not appear to work, it always returns false on the day specified. Can anyone help?

local tday = (os.date("%A"))
if (tday == "Wednesday") then
return true
else
return false
end

The %A format is locale dependent. Not sure if that’s an issue or not. I’d probably go with *t and get the day number from the table returned. Table contains year , month (1–12), day (1–31), hour (0–23), min (0–59), sec (0–61), wday (weekday, 1–7, Sunday is 1), yday (day of the year, 1–366), and isdst (daylight saving flag, a boolean)

Anticipating the question:

return os.date("*t")["wday"] == 4 

This returns true on Wednesday, false otherwise.

2 Likes

Thanks guys. What would I do without you. :smile:

1 Like