Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for conditional holidays #10

Closed
ckunki opened this issue Jun 4, 2021 · 1 comment · Fixed by #22
Closed

Add support for conditional holidays #10

ckunki opened this issue Jun 4, 2021 · 1 comment · Fixed by #22
Labels
enhancement New feature or request

Comments

@ckunki
Copy link
Collaborator

ckunki commented Jun 4, 2021

e.g. UK and Netherlands have cases in which

  • the holiday is on a fixed date
  • except if the date is a specific day of week then the holiday is some days off, e.g. on a Monday

Examples

Dutch holidays contains the following code meaning: if April 27 is a Sunday then April 26, otherwise April 27:

(holiday-sexp
 '(if (zerop (calendar-day-of-week (list  4 27 year)))
      (list  4 26 year)
    (list  4 27 year))
 "Koningsdag")

Uk-holidays describe New Year bank holiday, being on January 1st except if this is SAT or SUN, then next Monday:

(defun holiday-new-year-bank-holiday ()
  (let ((m displayed-month)
        (y displayed-year))
    (calendar-increment-month m y 1)
    (when (<= m 3)
      (let ((d (calendar-day-of-week (list 1 1 y))))
        (cond ((= d 6) `(((1 3 ,y) "New Year's Day Bank Holiday")))
              ((= d 0) `(((1 2 ,y) "New Year's Day Bank Holiday"))))))))

(defun holiday-christmas-bank-holidays ()
  (let ((m displayed-month)
        (y displayed-year))
    (calendar-increment-month m y -1)
    (when (>= m 10)
      (let ((d (calendar-day-of-week (list 12 25 y))))
        (cond ((= d 5) `(((12 28 ,y) "Boxing Day Bank Holiday")))
              ((= d 6) `(((12 27 ,y) "Boxing Day Bank Holiday")
			 ((12 28 ,y) "Christmas Day Bank Holiday")))
              ((= d 0) `(((12 27 ,y) "Christmas Day Bank Holiday"))))))))

In the following table X and B are Christmas and Boxing holidays defined anyway with a fixed date.
X2 and B2 are potential additional Christmas and Boxing holidays depending on the day of week of Dec 25th.

Case 25 26 27 28 Description
FRI SAT SUN MON
1 X B - B2 if DEC 25 is a FRI then 12 28 Boxing Day Bank Holiday
SAT SUN MON TUE
2 X B B2 X2 if DEC 25 is a SAT then 12 27 Boxing Day Bank Holiday and 12 28 Christmas Day Bank Holiday
SUN MON TUE WED
3 X B X2 if DEC 25 is a SUN then 12 27 Christmas Day Bank Holiday

Ideas for configuration file syntax

holiday either 4 27 or -1 if SUN Koningsdag
holiday if 4 27 is SUN then 4 26 Koningsdag
holiday except SUN 4 27 else 4 26 Koningsdag
holiday if-not SUN then 4 27 else 1 day before Koningsdag

holiday either fixed 4 27 or if SUN then fixed 4 26 Koningsdag
# leads to two holidays on Jan 1st in other cases
holiday either fixed JAN 1 or if SAT,SUN then float 1 MON after JAN 1 New Year's Day Bank Holiday
# leads to two Boxing holidays on Dec 26 in other cases
holiday either fixed DEC 26 or if SAT,SUN then float 1 MON after DEC 26 Boxing Day Bank Holiday
# leads to two Christmas holidays on Dec 25 in other cases
holiday either fixed DEC 25 or if SAT,SUN then float 1 TUE after DEC 25 Christmas Day Bank Holiday
@ckunki ckunki added the enhancement New feature or request label Jun 4, 2021
@ckunki
Copy link
Collaborator Author

ckunki commented Jun 5, 2021

Maybe we should make a difference between conditional holidays and holidays with alternative dates?

  • conditional holidays may be skipped in particular years without replacement, example
    holiday if DEC 26 is SAT,SUN then float 1 MON after DEC 26 Boxing Day Bank Holiday
  • holidays with alternative dates occur every year, but date may be different, example
    holiday either 4 27 or if SUN then fixed 4 26 Koningsdag

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant