Function: icalendar--convert-float-to-ical

icalendar--convert-float-to-ical is a byte-compiled function defined in icalendar.el.gz.

Signature

(icalendar--convert-float-to-ical NONMARKER ENTRY-MAIN)

Documentation

Convert float diary entry to iCalendar format -- partially unsupported!

  FIXME! DAY from diary-float yet unimplemented.

  NONMARKER is a regular expression matching the start of non-marking
  entries. ENTRY-MAIN is the first line of the diary entry.

Source Code

;; Defined in /usr/src/emacs/lisp/calendar/icalendar.el.gz
(defun icalendar--convert-float-to-ical (nonmarker entry-main)
  "Convert float diary entry to iCalendar format -- partially unsupported!

  FIXME! DAY from `diary-float' yet unimplemented.

  NONMARKER is a regular expression matching the start of non-marking
  entries.  ENTRY-MAIN is the first line of the diary entry."
  (if (string-match (concat nonmarker "%%\\((diary-float .+\\) ?$") entry-main)
      (with-temp-buffer
        (insert (match-string 1 entry-main))
        (goto-char (point-min))
        (let* ((sexp (read (current-buffer))) ;using `read' here
					      ;easier than regexp
					      ;matching, esp. with
					      ;different forms of
					      ;MONTH
               (month (nth 1 sexp))
               (dayname (nth 2 sexp))
               (n (nth 3 sexp))
               (day (nth 4 sexp))
               (summary
                (replace-regexp-in-string
		 "\\(^\s+\\|\s+$\\)" ""
		 (buffer-substring (point) (point-max)))))

          (when day
            (progn
              (icalendar--dmsg "diary-float %s" entry-main)
              (error "Don't know if or how to implement day in `diary-float'")))

          (cons (concat
                 ;;Start today (yes this is an arbitrary choice):
                 "\nDTSTART;VALUE=DATE:"
                 (format-time-string "%Y%m%d")
                 ;;BUT remove today if `diary-float'
                 ;;expression does not hold true for today:
                 (when
                     (null (calendar-dlet ((date (calendar-current-date))
                                           (entry entry-main))
                             (diary-float month dayname n)))
                   (concat
                    "\nEXDATE;VALUE=DATE:"
                    (format-time-string "%Y%m%d")))
                 "\nRRULE:"
                 (if (or (numberp month) (listp month))
                     "FREQ=YEARLY;BYMONTH="
                   "FREQ=MONTHLY")
                 (when
                     (listp month)
                   (mapconcat
                    (lambda (m)
                      (number-to-string m))
                    (cadr month) ","))
                 (when
                     (numberp month)
                   (number-to-string month))
                 ";BYDAY="
                 (number-to-string n)
		 (aref icalendar--weekday-array dayname))
                summary)))
    ;; no match
    nil))