Function: org-icalendar--vtodo
org-icalendar--vtodo is a byte-compiled function defined in
ox-icalendar.el.gz.
Signature
(org-icalendar--vtodo ENTRY UID SUMMARY LOCATION DESCRIPTION CATEGORIES TIMEZONE CLASS)
Documentation
Create a VTODO component.
ENTRY is either a headline or an inlinetask element. UID is the unique identifier for the task. SUMMARY defines a short summary or subject for the task. LOCATION defines the intended venue for the task. CLASS sets the task class (e.g. confidential). DESCRIPTION provides the complete description of the task. CATEGORIES defines the categories the task belongs to. TIMEZONE specifies a time zone for this TODO only.
Return VTODO component as a string.
Source Code
;; Defined in /usr/src/emacs/lisp/org/ox-icalendar.el.gz
(defun org-icalendar--vtodo
(entry uid summary location description categories timezone class)
"Create a VTODO component.
ENTRY is either a headline or an inlinetask element. UID is the
unique identifier for the task. SUMMARY defines a short summary
or subject for the task. LOCATION defines the intended venue for
the task. CLASS sets the task class (e.g. confidential). DESCRIPTION
provides the complete description of the task. CATEGORIES defines the
categories the task belongs to. TIMEZONE specifies a time zone for
this TODO only.
Return VTODO component as a string."
(let* ((sc (and (memq 'todo-start org-icalendar-use-scheduled)
(org-element-property :scheduled entry)))
(dl (and (memq 'todo-due org-icalendar-use-deadline)
(org-element-property :deadline entry)))
(sc-repeat-p (org-icalendar--repeater-type sc))
(dl-repeat-p (org-icalendar--repeater-type dl))
(repeat-value (or (org-element-property :repeater-value sc)
(org-element-property :repeater-value dl)))
(repeat-unit (or (org-element-property :repeater-unit sc)
(org-element-property :repeater-unit dl)))
(repeat-until (and sc-repeat-p (not dl-repeat-p) dl))
(start
(cond
(sc)
((eq org-icalendar-todo-unscheduled-start 'current-datetime)
(let ((now (decode-time)))
(list 'timestamp
(list :type 'active
:minute-start (nth 1 now)
:hour-start (nth 2 now)
:day-start (nth 3 now)
:month-start (nth 4 now)
:year-start (nth 5 now)))))
((or (and (eq org-icalendar-todo-unscheduled-start
'deadline-warning)
dl)
(and (eq org-icalendar-todo-unscheduled-start
'recurring-deadline-warning)
dl-repeat-p))
(let ((dl-raw (org-element-property :raw-value dl)))
(with-temp-buffer
(insert dl-raw)
(goto-char (point-min))
(org-timestamp-down-day (org-get-wdays dl-raw))
(org-element-timestamp-parser)))))))
(concat "BEGIN:VTODO\n"
"UID:TODO-" uid "\n"
(org-icalendar-dtstamp) "\n"
(when start (concat (org-icalendar-convert-timestamp
start "DTSTART" nil timezone)
"\n"))
(when (and dl (not repeat-until))
(concat (org-icalendar-convert-timestamp
dl "DUE" nil timezone)
"\n"))
;; RRULE
(cond
;; SCHEDULED, DEADLINE have different repeaters
((and dl-repeat-p
(not (and (eq repeat-value (org-element-property
:repeater-value dl))
(eq repeat-unit (org-element-property
:repeater-unit dl)))))
;; TODO Implement via RDATE with changing DURATION
(org-display-warning "Not yet implemented: \
different repeaters on SCHEDULED and DEADLINE. Skipping.")
nil)
;; DEADLINE has repeater but SCHEDULED doesn't
((and dl-repeat-p (and sc (not sc-repeat-p)))
;; TODO SCHEDULED should only apply to first instance;
;; use RDATE with custom DURATION to implement that
(org-display-warning "Not yet implemented: \
repeater on DEADLINE but not SCHEDULED. Skipping.")
nil)
((or sc-repeat-p dl-repeat-p)
(concat
(org-icalendar--rrule repeat-unit repeat-value)
;; add UNTIL part to RRULE
(when repeat-until
(let* ((start-time
(org-element-property :minute-start start))
;; RFC5545 requires UTC iff DTSTART is not local time
(local-time-p
(and (not timezone)
(equal org-icalendar-date-time-format
":%Y%m%dT%H%M%S")))
(encoded
(org-encode-time
0
(or (org-element-property :minute-start repeat-until)
0)
(or (org-element-property :hour-start repeat-until)
0)
(org-element-property :day-start repeat-until)
(org-element-property :month-start repeat-until)
(org-element-property :year-start repeat-until))))
(concat ";UNTIL="
(cond
((not start-time)
(format-time-string "%Y%m%d" encoded))
(local-time-p
(format-time-string "%Y%m%dT%H%M%S" encoded))
((format-time-string "%Y%m%dT%H%M%SZ"
encoded t))))))
"\n")))
"SUMMARY:" summary "\n"
(and (org-string-nw-p location) (format "LOCATION:%s\n" location))
(and (org-string-nw-p class) (format "CLASS:%s\n" class))
(and (org-string-nw-p description)
(format "DESCRIPTION:%s\n" description))
"CATEGORIES:" categories "\n"
"SEQUENCE:1\n"
(format "PRIORITY:%d\n"
(let ((pri (or (org-element-property :priority entry)
org-priority-default)))
(floor (- 9 (* 8. (/ (float (- org-priority-lowest pri))
(- org-priority-lowest
org-priority-highest)))))))
(format "STATUS:%s\n"
(if (eq (org-element-property :todo-type entry) 'todo)
"NEEDS-ACTION"
"COMPLETED"))
"END:VTODO\n")))