;;; ymh-diary.el --- Extensions to the Emacs Diary -*- lexical-binding: t; -*- ;;; 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 &optional mark) "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." (with-no-warnings (defvar date) (defvar entry)) (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)) ) (cons mark 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))) (defun ymh-diary-org-export-to-ics () "Export diary file to ICal format." (with-temp-buffer (insert-file-contents diary-file) (setq ics-file-body (org-diary-to-ical-string (current-buffer)))) (with-temp-file "~/Downloads/emacs.ics" (insert "BEGIN:VCALENDAR PRODID:-//E-DIARY//E-DIARY 1.0//EN VERSION:2.0 METHOD:PUBLISH X-WR-CALNAME:Emacs X-Built-On-Cache-Miss:true " ics-file-body "END:VCALENDAR"))) (defun ymh-diary-export-to-ics () "Export the current diary to ICS format." (interactive) (icalendar-export-file diary-file (expand-file-name "emacs.ics" "~/Downloads"))) (provide 'ymh-diary) ;;; ymh-diary.el ends here