Archive for 2018年11月|Monthly archive page
newLISP で祝祭日を計算する(改)
2019年と2020年の祝日は特例が多いようなので別掲載にしました。
と言っても、今回は2019年対応です(笑)
(define *WeekDays* '("Sun" "Mon" "Tue" "Wed" "Thu" "Fri" "Sat"))
(define (vernal year) ; 春分の日
(if (and (<= 2000 year) (< year 2100))
(- (add 20.69115 (mul 0.242194 (- year 2000))) (/ (- year 2000) 4))))
(define (autumnal year) ; 秋分の日
(if (and (<= 2000 year) (< year 2100))
(- (add 23.09 (mul 0.242194 (- year 2000))) (/ (- year 2000) 4))))
(define (anniversary year month)
(let (i (find (0 3 (date (date-value year month 1))) *WeekDays*)
res '())
(case month
( 1 (push (list year 1 1 '元日) res -1) ; 元日
(if (= i 0) (push (list year 1 2 '振替休日) res -1))
(push (if ( year 2019) (push (list year 2 23 '天皇誕生日) res -1) ; 天皇誕生日
(if (= i 6) (push (list year 2 24 '振替休日) res -1))) )
( 3 (push (list year 3 (vernal year) '春分の日) res -1) ; 春分の日
(if (= i (- 22 ((res -1) 2))) (push (list year 3 (+ 1 ((res -1) 2)) '振替休日) res -1)) )
( 4 (push (list year 4 29 '昭和の日) res -1) ; 昭和の日
(if (= i 0) (push (list year 4 30 '振替休日) res -1))
(when (= year 2019)
(push (list year 4 30 '特別振替休日(非確定)) res -1)
) )
( 5 (push (list year 5 3 '憲法記念日) res -1) ; 憲法記念日
(push (list year 5 4 'みどりの日) res -1) ; みどりの日
(push (list year 5 5 'こどもの日) res -1) ; こどもの日
(if (and (< 2 i) (< i 6)) (push (list year 5 6 '振替休日) res -1))
(when (= year 2019)
(push (list year 5 1 '特別祝日(非確定)) res -1)
(push (list year 5 2 '特別振替休日(非確定)) res -1)
) )
( 6 )
( 7 (push (if ( year 2015)
(push (list year 8 11 '山の日) res -1) ; 山の日
(if (= i 4) (push (list year 8 12 '振替休日) res -1))))
( 9 (push (if (< i 2) ; 敬老の日 : 9月第3月曜日
(list year 9 (- 16 i) '敬老の日) ; 2 + 2 * 7
(list year 9 (- 23 i) '敬老の日)) ; 2 + 3 * 7
res -1)
(push (list year 9 (autumnal year) '秋分の日) res -1) ; 秋分の日
(if (= i (- 29 ((res -1) 2)) (push (list year 9 (+ 1 ((res -1) 2)) '振替休日) res -1)) )
(if (= 2 (- ((res 1) 2) ((res 0) 2)))
(push (list year 9 (- ((res -1) 2) 1) '国民の休日) res 1)) )
(10 (push (if (< i 2) ; 体育の日 : 10月第2月曜日
(list year 10 (- 9 i) '体育の日) ; 2 + 1 * 7
(list year 10 (- 16 i) '体育の日)) ; 2 + 2 * 7
res -1)
(when (= year 2019)
(push (list year 11 22 '即位礼正殿の儀休日(非確定)) res -1)) )
(11 (push (list year 11 3 '文化の日) res -1) ; 文化の日
(if (= i 5) (push (list year 11 4 '振替休日) res -1))
(push (list year 11 23 '勤労感謝の日) res -1) ; 勤労感謝の日
(if (= i 6) (push (list year 11 24 '振替休日) res -1)))
(12 (when (< year 2019) (push (list year 12 23 '天皇誕生日) res -1) ; 天皇誕生日
(if (= i 6) (push (list year 12 24 '振替休日) res -1)) ))
(true ))
res))
さて、これを使って VCSファイルを作るにはこちらのスクリプトをお使いください。
2019年のVCSファイルはこちらに掲載しています。
以上、如何でしょうか?