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.
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
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. On the other hand, I probably shouldn’t be worried about it being up and running in the year 2100 either.