Cancel
Showing results for 
Search instead for 
Did you mean: 

Hafl-Day Shift Last Friday of Month

Solution Partner Valued Contributor Solution Partner Valued Contributor
Solution Partner Valued Contributor

Hi guys

 

I'm busy with a model with the following shift pattern:

Shift.JPG

 

On the last Friday of each month, Shift-1 works from 6:10 - 10:10. (Shift 2 and 3 are constant)

 

I am not sure if the Calendar Tab will cater for this beacuse if you entered a reduced time (00:00 - 10:10) then SHifts 2 and 3 will not work.

 

I am thinking of having an observer look at a variable called "DAY_Number" that changes each day using  dayofweek(eventcontroller.abssimtime) and once the last friday of the month is hit it will import the following using shiftcalendar.shiftplan

Shift Last Friday.JPG

 

This method will be tedious because the last fridays of each month will have to be set manually.

 

Any suggestions to improve/change this approach?

 

Regards,

Hermias

3 REPLIES

Re: Hafl-Day Shift Last Friday of Month

Gears Esteemed Contributor Gears Esteemed Contributor
Gears Esteemed Contributor
if you check the date and if you found a Friday --> add a week to the actual absSimTime and check the month --> if it is another month --> last friday
Steffen Bangsow
freelance simulation specialist  
web: www.bangsow.eu
mail: steffen@bangsow.net

Re: Hafl-Day Shift Last Friday of Month

Solution Partner Valued Contributor Solution Partner Valued Contributor
Solution Partner Valued Contributor

What about something like triggering a method like the one below anytime you identify a friday.

 

is
month:integer;
friday:integer;
do
inspect month 
      when 2 then
           if Friday>21 then
                 "change calendar since it will be last friday";
           end;
      when 1,3,5,7,8,10,12 then
            if Friday>24 then
                 "change calendar since it will be last friday";
           end;
      else
            if Friday>23 then
                 "change calendar since it will be last friday";
           end;
      end;
not

 

 

Regards,

cortega@interlatin.com.mx
+52 (81) 10801310
InterLatin S de RL de CV

Re: Hafl-Day Shift Last Friday of Month

Solution Partner Valued Contributor Solution Partner Valued Contributor
Solution Partner Valued Contributor

Thanks for the feedback!

I used the following method and it works perfectly Smiley Happy

 

--Called as observer on day_number variable
(attribute: string; oldValue: any)
is
do
	local x:= month(eventcontroller.abssimTime);
	--add one week to check if this Friday is last friday of month
	local z := eventcontroller.abssimTime + str_to_time("7:00:00:00");
	
	local y:= month(z); 
	
	if day_Number = 5 then --5 = Friday
		if x/=y then --different month
			shiftcalendar_2E.shiftPlan := import_shifts_LAST_FRIDAY;
			
		end;
	elseif day_number = 0 or day_Number = 1  or day_Number = 6 then --import regular shifts on SAturday, SUnday or Monday
		shiftcalendar_20E_CSR.shiftPlan := import_shifts_2E;
			
	end;		
end;