From: Dave S. <da...@st...> - 2008-05-15 10:44:32
|
mo...@be... wrote: > Hi Andy, > > Thanks for the reply/suggestion! > > >> Hi, >> >> I think the problem is in the statement below. The time_greater_than() >> function cannot handle clock based mathematics. >> >> if (time_greater_than "$Time_Sunset - 0:15" or >> time_less_than "$Time_Sunrise - 0:15") >> >> So try using the time_add() function to first do the mathematics. >> >> if (time_greater_than(time_add "$Time_Sunset - 0:15") or >> time_less_than(time_add "$Time_Sunrise - 0:15")) >> > > The good thing about Perl is that there are 1001 ways to do something. > The bad thing about Perl is that there are 1001 ways to do something. > :) > > I'd not found 'time_add' before. Good one to know about. > > >> Let us know how you get on. >> > > Sadly, that method doesn't turn my garage light on either. > > The code loads, meaning that Perl/mh doesn't see anything wrong with > the syntax; but apparently my logic is flawed. > > if (time_greater_than(time_add "$Time_Sunset - 0:15") or > time_less_than(time_add "$Time_Sunrise - 0:15")) > { > set $Garage_Light 'on'; > } > > > >> Andy. >> >> > > How about using time_between instead? if (time_between $Time_Sunset and $Time_Sunrise) { set $Garage_Light 'on'; } Then play with the offsets. I don't have any code that does exactly what you're trying to do here, but I have some that has "$Time_Sunset - 0:30" and that piece works well, and I have a lot of "time_between" in my private code. Good Luck! -Dave |