summaryrefslogtreecommitdiffstats
path: root/ymh-emacs/ymh-diary.el
blob: 343d3315f8541ad7dc4b559583045e05aab596bd (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
;;; ymh-diary.el --- Extensions to the Emacs Diary  -*- lexical-binding: t; -*-

;; Author: Yann Herklotz <git@yannherklotz.com>
;; Package-Requires: ((emacs "24.3"))

;;; Commentary:

;; This file contains extensions to the built-in Emacs Diary.  Mainly, it adds a
;; timezone conversion to the diary display function, so that if

;;; Code:

(defun ymh-diary-schedule (y1 m1 d1 y2 m2 d2 dayname)
  "Entry applies if date is between dates on DAYNAME.
    Order of the parameters is M1, D1, Y1, M2, D2, Y2 if
    `european-calendar-style' is nil, and D1, M1, Y1, D2, M2, Y2 if
    `european-calendar-style' is t. Entry does not apply on a history."
  (let ((date1 (calendar-absolute-from-gregorian (list m1 d1 y1)))
        (date2 (calendar-absolute-from-gregorian (list m2 d2 y2)))
        (d (calendar-absolute-from-gregorian date)))
    (if (and
         (<= date1 d)
         (<= d date2)
         (= (calendar-day-of-week date) dayname)
         ;;(not (calendar-check-holidays date))
         )
        entry)))

(defun ymh-diary-last-day-of-month (date)
  "Return `t` if DATE is the last day of the month."
  (let* ((day (calendar-extract-day date))
         (month (calendar-extract-month date))
         (year (calendar-extract-year date))
         (last-day-of-month
          (calendar-last-day-of-month month year)))
    (= day last-day-of-month)))

(provide 'ymh-diary)

;;; ymh-diary.el ends here