Is this right?

My goal is to have only allow a scene to run between 21:30 to sunrise. Using the sample code I think I figured out how to do it but I’m not quite sure. Does the below code look right?

local pStart = “21:30”
local pEnd = 0
local allow = true
local mStart = math.floor( (luup.sunrise() % 86400) / 60 ) [color=red]+ pStart --I don’t need this because I want it to run all the way to sunrise, right?[/color]
local hE, mE = string.match(pStart,“(%d+)%:(%d+)”)
local mEnd = (hE * 60) + mE
local tNow = os.date(“*t”)
local mNow = (tNow.hour * 60) + tNow.min
if mEnd >= mStart then
return (((mNow >= mStart) and (mNow <= mEnd)) == allow)
else
return (((mNow >= mStart) or (mNow <= mEnd)) == allow)
end

Thanks

Use the “START TIME TO SUNRISE” example from Rex’s post:

http://forum.micasaverde.com/index.php/topic,18679.msg141954.html#msg141954

local pStart = “22:30” – Start of time period
local pEnd = 0 – End of time period, minutes offset from sunrise
local allow = true – true runs scene during period, false blocks it
local hS, mS = string.match(pStart,“(%d+)%:(%d+)”)
local mStart = (hS * 60) + mS
local mEnd = math.floor( (luup.sunrise() % 86400) / 60 ) + pEnd
local tNow = os.date(“*t”)
local mNow = (tNow.hour * 60) + tNow.min
if mEnd >= mStart then
return (((mNow >= mStart) and (mNow <= mEnd)) == allow)
else
return (((mNow >= mStart) or (mNow <= mEnd)) == allow)
end

I didn’t see that one.

Thanks.