Archive for 2019年11月|Monthly archive page
newLISP で祝祭日を計算する(改2)
ようやく、2020年以降にも対応しました(汗)
(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 (if (= year 2020) (begin (push (list year 7 23 '海の日) res -1)
(push (list year 7 24 'スポーツの日) res -1))
(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 (if (< year 2000) (push (list year 10 10 '体育の日) res -1)
(< year 2020)
(push (if ( year 2020)
(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 10 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ファイルを作るにはこちらのスクリプトをお使いください。
2020年のVCSファイルはこちらに掲載しています。
以上、如何でしょうか?