I’m trying to figure out how to determine the day of the week with Luup code (I have an event that fires on week days but I don’t want it to fire at the weekend so the only way I can see to do it is with code, there are no check boxes with an event), can anyone help with this please?
Thanks but still can’f figure out how to extract the day of week out of this. I understand wday is part of a table, I just can’t figure out how to get it out of the table.
Thanks agian for any help. I’m a total newbie as you can tell.
local t = os.date ("*t")
local weekdays = {
"Sunday",
"Monday",
"Tuesday",
"Wednesday",
"Thursday",
"Friday",
"Saturday"
}
luup.log ("Today is day " .. t.wday .. " of the week, which means " .. weekdays[t.wday])
Thanks much. I was just reading all about tables and had figured out:
– Check to see if it’s the weekend
local dy = os.date(“*t”)
local day_of_week = dy.wday
if (day_of_week == 1) or (day_of_week == 7) then
return false
end
But didn’t know how to assign a name to them so that is helpful.