Figuring out the day of the week with Luup code

Hi,

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 in advance for your help,

Mark

Try os.date

[url=http://www.lua.org/manual/5.1/manual.html#pdf-os.date]Lua 5.1 Reference Manual

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.

Mark

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])

The code above will print:

Today is day 5 of the week, which means Thursday

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.

Thanks again,

Mark

print(os.date("%A", os.time()))