Function: icalendar--convert-ordinary-to-ical
icalendar--convert-ordinary-to-ical is a byte-compiled function
defined in icalendar.el.gz.
Signature
(icalendar--convert-ordinary-to-ical NONMARKER ENTRY-MAIN)
Documentation
Convert "ordinary" diary entry to iCalendar format.
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
;; subroutines for icalendar-export-region
(defun icalendar--convert-ordinary-to-ical (nonmarker entry-main)
"Convert \"ordinary\" diary entry to iCalendar format.
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
"\\([^ /]+[ /]+[^ /]+[ /]+[^ ]+\\)\\s-*" ; date
"\\(\\([0-9][0-9]?\\(:[0-9][0-9]\\)?\\)\\([ap]m\\)?" ; start time
"\\("
"-\\([0-9][0-9]?\\(:[0-9][0-9]\\)?\\)\\([ap]m\\)?\\)?" ; end time
"\\)?"
"\\s-*\\(.*?\\) ?$")
entry-main)
(let* ((datetime (substring entry-main (match-beginning 1)
(match-end 1)))
(startisostring (icalendar--datestring-to-isodate
datetime))
(endisostring (icalendar--datestring-to-isodate
datetime 1))
(endisostring1)
(starttimestring (icalendar--diarytime-to-isotime
(if (match-beginning 3)
(substring entry-main
(match-beginning 3)
(match-end 3))
nil)
(if (match-beginning 5)
(substring entry-main
(match-beginning 5)
(match-end 5))
nil)))
(endtimestring (icalendar--diarytime-to-isotime
(if (match-beginning 7)
(substring entry-main
(match-beginning 7)
(match-end 7))
nil)
(if (match-beginning 9)
(substring entry-main
(match-beginning 9)
(match-end 9))
nil)))
(summary (icalendar--convert-string-for-export
(substring entry-main (match-beginning 10)
(match-end 10)))))
(icalendar--dmsg "ordinary %s" entry-main)
(unless startisostring
(error "Could not parse date"))
;; If only start-date is specified, then end-date is next day,
;; otherwise it is same day.
(setq endisostring1 (if starttimestring
startisostring
endisostring))
(when starttimestring
(unless endtimestring
(let ((time
(read (replace-regexp-in-string "^T0?" ""
starttimestring))))
(if (< time 230000)
;; Case: ends on same day
(setq endtimestring (format "T%06d"
(+ 10000 time)))
;; Case: ends on next day
(setq endtimestring (format "T%06d"
(- time 230000)))
(setq endisostring1 endisostring)) )))
(cons (concat "\nDTSTART;"
(if starttimestring "VALUE=DATE-TIME:"
"VALUE=DATE:")
startisostring
(or starttimestring "")
"\nDTEND;"
(if endtimestring "VALUE=DATE-TIME:"
"VALUE=DATE:")
endisostring1
(or endtimestring ""))
summary))
;; no match
nil))