Function: diary-icalendar-date-sexp-to-recurrence

diary-icalendar-date-sexp-to-recurrence is a byte-compiled function defined in diary-icalendar.el.gz.

Signature

(diary-icalendar-date-sexp-to-recurrence SEXP)

Documentation

Convert a diary-date SEXP to an icalendar-rrule or icalendar-rdate node.

Returns a pair of nodes (START R), where START is an icalendar-dtstart node and R is the RRULE or RDATE node.

Source Code

;; Defined in /usr/src/emacs/lisp/calendar/diary-icalendar.el.gz
(defun di:date-sexp-to-recurrence (sexp)
  "Convert a `diary-date' SEXP to an `icalendar-rrule' or `icalendar-rdate' node.
Returns a pair of nodes (START R), where START is an `icalendar-dtstart'
node and R is the RRULE or RDATE node."
  (let* ((d1 (nth 1 sexp))
         (d2 (nth 2 sexp))
         (d3 (nth 3 sexp))
         years months days)
    (cl-case calendar-date-style
      (iso (setq years (if (integerp d1) (list d1) d1)
                 months (if (integerp d2) (list d2) d2)
                 days (if (integerp d3) (list d3) d3)))
      (american (setq months (if (integerp d1) (list d1) d1)
                      days (if (integerp d2) (list d2) d2)
                      years (if (integerp d3) (list d3) d3)))
      (european (setq days (if (integerp d1) (list d1) d1)
                      months (if (integerp d2) (list d2) d2)
                      years (if (integerp d3) (list d3) d3))))

    ;; unquote lists of integers read as quoted lists:
    (when (and (listp months) (eq 'quote (car months)))
      (setq months (eval months nil)))
    (when (and (listp days) (eq 'quote (car days)))
      (setq days (eval days nil)))
    (when (and (listp years) (eq 'quote (car years)))
      (setq years (eval years nil)))

    ;; if at this point we don't have lists of integers or "t", user
    ;; entered a malformed diary-date sexp:
    (unless (or (eq months t) (seq-every-p #'integerp months))
      (di:signal-export-error
       (format "Malformed months in `diary-date' S-expression:\n%s" sexp)))
    (unless (or (eq days t) (seq-every-p #'integerp days))
      (di:signal-export-error
       (format "Malformed days in `diary-date' S-expression:\n%s" sexp)))
    (unless (or (eq years t) (seq-every-p #'integerp years))
      (di:signal-export-error
       (format "Malformed years in `diary-date' S-expression:\n%s" sexp)))

    (di:dates-to-recurrence months days years)))