月の平日を数える
月の平日を数えるlisp
((lambda (y m) ;基点日付作成 (setq date (encode-universal-time 0 0 0 1 m y)) ;月替わりの検出 (setq wDate (format-date-string "%m" date)) ;初期値設定 (setq x 0) (setq cnt 0) (setq cnt2 0) ;祝日取得 (setq holiday (make-vector 33)) (ed::calendar-japanese-holiday y m holiday) ;無限ループ (loop ;日時設定 (setq date (encode-universal-time 0 0 0 (+ x 1) m y)) ;月が替わったら終了 (if (not (equalp (format-date-string "%m" date) wDate) ) (return) ) ;日付を進める (setq x (+ x 1)) ;日を出力 (cond ((typep (aref holiday x) 'string) (setq cnt (+ cnt 1))) ((equalp (format-date-string "%v" date ) "土") (setq cnt (+ cnt 1))) ((equalp (format-date-string "%v" date ) "日") (setq cnt (+ cnt 1))) (t (setq cnt2 (+ cnt2 1))) ) ) (insert (format nil "土日祝日:~D~%平日:~D~%" cnt cnt2)) ) 2010 2) 土日祝日:9 平日:19 t
地下鉄の定期券を買うかどうか考えるのに作りました。