New Scheduler Example


#1

In taking a look at the scheduler example that was recently posted, it looks like it doesn’t handle leap years. In my scheduler I use a script block such as this to test for leap year:

Current_Year = GetYear();
if ((Current_Year % 4) == 0) then
if ((Current_Year % 100) <> 0) then
SetVariableTrue(Leap_Year);
else
SetVariableFalse(Leap_Year);
endif
else
SetVariableFalse(Leap_Year);
endif

Just something to consider… personally, I think Feb. 29th should just always be a holiday. :stuck_out_tongue:


#2

Hello rcbourn, you missed a condition: multiples of 400 are also leap years. It is important when the code “walks” across year 2000, as very often happens when interacting with C and Java programs.
This is my piece of code for leap years:

y=GetYear();
If (y%4 == 0 and (y%100 <> 0 Or y%400 == 0)) then 
    leap=1; 
else 
   leap=0; 
endif

#3

Good point… I wasn’t worried about it because we are only scheduling future events… and I don’t expect the system to be up and running in the year 2400. :slight_smile: On the other hand, I probably shouldn’t be worried about it being up and running in the year 2100 either.


#4

Thanks very much you guys for this! This is just the sort of hints and tips we are looking for.

And as for the Opto system not being up and running in the year 2100… it is Opto you know…

Ben