cal icon indicating copy to clipboard operation
cal copied to clipboard

"Bridge" holidays

Open mblasi opened this issue 3 years ago • 4 comments

Hello, here in Argentina, we have a rule for promote turism, which adds Friday as holiday when the real one is Thursday, and adds Monday when it is Tuesday. Is there any way to represent it with the new v2 api?

Thanks!

mblasi avatar May 23 '21 13:05 mblasi

There's no built-in way to do that. You should be able to create a custom HolidayFn that returns Friday or Tuesday after checking if the original holiday is on Thursday or Tuesday.

rickar avatar May 27 '21 00:05 rickar

Thank you @rickar! If I understand correctly, that HolidayFn would swap the "Thursday" with "Friday", but in my case, we need to add Friday, and finally should be two holidays: Thursday and Friday.

mblasi avatar May 27 '21 12:05 mblasi

Right. Each Holiday definition can only return one day per year so you would need to create something like TruthDay and SecondTruthDay. TruthDay would return the normal holiday every year like you currently have it with CalcDayOfMonth and SecondTruthDay would use a custom CalcBridgeDay that returns the extra day if it applies or zero time if not.

rickar avatar May 29 '21 13:05 rickar

I see. So I should define this "second" day for each actual holiday...

El sáb., 29 de mayo de 2021 10:58, rickar @.***> escribió:

Right. Each Holiday definition can only return one day per year so you would need to create something like TruthDay and SecondTruthDay. TruthDay would return the normal holiday every year like you currently have it with CalcDayOfMonth and SecondTruthDay would use a custom CalcBridgeDay that returns the extra day if it applies or zero time if not.

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/rickar/cal/issues/67#issuecomment-850838021, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAAJZGPJ2X6G7G4GPQQB5ITTQDXHLANCNFSM45LWNVIQ .

mblasi avatar May 29 '21 16:05 mblasi