[Message Prev][Message Next][Thread Prev][Thread Next][Message Index][Thread Index]

Re: japanese-holidays.el



田中と申します。

At 18 Jan 2001 22:02:15 +0900,
Norihiro Morimoto wrote:
> 
> Morimotoです。
> 
> japanese-holidays.elを使って、休日の表示が出来るようになりました。
> 一つ、疑問があります。それは、以下のように表示すると、2001年12月
> 23日の振り替え休日である24日が赤くならないのです。
>  ・
> (略)
>  ・

japanese-holidays.elを拝見しましたが、これは

(defun holiday-fixed-furikae (m d s)
  (append (holiday-fixed m d s)
	  (and (= (calendar-day-of-week (list m d displayed-year)) 0)
	       (holiday-fixed m (1+ d) "振替休日"))))

の3行目のdisplayed-yearが問題だと思われます。つまり、displayed-yearは
真中に表示されている月の年になりますが、2001年12月を左部分に表示すると、
displayed-yearは2002(年)になってしまうので、3行目の

(= (calendar-day-of-week (list m d displayed-year)) 0)

は2002年の天皇誕生日を判定してしまっています。
よって振替休日が生成されません。

`h'(calendar-cursor-holidays)を実行したときは、holidays.elの

(defun check-calendar-holidays (date)
  "Check the list of holidays for any that occur on DATE.
The value returned is a list of strings of relevant holiday descriptions.
The holidays are those in the list calendar-holidays."
  (let* ((displayed-month (extract-calendar-month date))
         (displayed-year (extract-calendar-year date)) <- ここ

でカーソルのある日の年(2001)が入るので問題ないのでしょう。

自分の場合はholiday-fixed-furikaeを使わずに振替休日を含めた国民の祝日を
定義しています。解決策というか、japanese-holidays.elのgeneral-holidays-JPを
以下の様にしては如何でしょうか。ハッピーマンデーにも対応しています。
よろしければご参考まで。

(defvar general-holidays-JP
  '((holiday-fixed  1  1  "元旦")
    (holiday-float  1 1 2 "成人の日")
    (holiday-fixed  2 11  "建国記念の日")
    (holiday-fixed  4 29  "みどりの日")
    (holiday-fixed  5  3  "憲法記念日")
    (holiday-fixed  5  4  "国民の休日")
    (holiday-fixed  5  5  "こどもの日")
    (holiday-fixed  7 20  "海の日")
    (holiday-fixed  9 15  "敬老の日")
    (holiday-float 10 1 2 "体育の日")
    (holiday-fixed 11  3  "文化の日")
    (holiday-fixed 11 23  "勤労感謝の日")
    (holiday-fixed 12 23  "天皇誕生日")
    ;; 春分の日と秋分の日
    (if (memq displayed-month '(2 3 4 8 9 10))
        (solar-equinoxes-solstices))
    ;; 振替休日
    (when (not (boundp 'called-recursively))
      (let* (called-recursively
             (month displayed-month)
             (year displayed-year)
             (day (progn
                    (increment-calendar-month month year -2)
                    (list month (calendar-last-day-of-month month year) year)))
             (calendar-holidays general-holidays-JP) ;; ここ変数名と同じにする
             (holiday-list (calendar-holiday-list))
             holiday mmday ret)
        (if (check-calendar-holidays day)
            (setq holiday-list (cons (list day "dummy") holiday-list)))
        (while holiday-list
          (setq holiday (caar holiday-list))
          (and (= (calendar-day-of-week holiday) 0)
               (setq mmday (calendar-gregorian-from-absolute
                            (1+ (calendar-absolute-from-gregorian holiday))))
               (null (check-calendar-holidays mmday))
               (setq ret (cons (list mmday "振替休日") ret)))
          (setq holiday-list (cdr holiday-list)))
        ret))))



---
Shingo TANAKA  mailto:shingo@xxxxxxxxxxxxxxxxxxxx