Function: icalendar-parse-calendar

icalendar-parse-calendar is a byte-compiled function defined in icalendar-parser.el.gz.

Signature

(icalendar-parse-calendar LIMIT)

Documentation

Parse an icalendar-vcalendar object from point up to LIMIT.

Point should be at the start of the calendar object, i.e., at the start of a line that looks like "BEGIN:VCALENDAR". After parsing, point is at the beginning of the next line following the calendar (or end of the buffer). Returns a syntax node representing the calendar.

Source Code

;; Defined in /usr/src/emacs/lisp/calendar/icalendar-parser.el.gz
;; `icalendar-parse-component' is sufficient to parse all the syntax in
;; a calendar, but a calendar-level parsing function is needed to add
;; support for time zones.  This function ensures that every
;; `icalendar-tzidparam' in the calendar has a corresponding
;; `icalendar-vtimezone' component, and modifies the zone information of
;; the parsed date-time according to the offset in that time zone.
(defun ical:parse-calendar (limit)
  "Parse an `icalendar-vcalendar' object from point up to LIMIT.
Point should be at the start of the calendar object, i.e., at the start
of a line that looks like \"BEGIN:VCALENDAR\".  After parsing, point is
at the beginning of the next line following the calendar (or end of the
buffer).  Returns a syntax node representing the calendar."
  (require 'icalendar-recur) ; for icr:tz-set-zones-in; avoids circular require
  (declare-function icr:tz-set-zones-in "icalendar-recur")
  (unless (looking-at-p "^BEGIN:VCALENDAR")
    (ical:signal-parse-error "Not at start of VCALENDAR"))
  (let ((cal-node (ical:parse-component limit)))
      ;(when (ical:ast-node-valid-p cal-node t)
      (ical:with-component cal-node
          ((ical:vtimezone :all tzs))
        ;; After parsing the whole calendar, set the zone and dst slots
        ;; in all date-times which are relative to a time zone defined
        ;; in the calendar:
        ;; (TODO: if this proves too slow in general, we could instead
        ;; do it lazily when individual components are queried somehow.
        ;; But I'm not convinced that will actually save any time, because
        ;; if we're parsing, we're probably already in the middle of a
        ;; function that will immediately query all these times, e.g.
        ;; `diary-icalendar-import-buffer'.)
        (dolist (comp (ical:ast-node-children cal-node))
          (unless (ical:vtimezone-component-p comp)
            (icr:tz-set-zones-in tzs comp))));)
      cal-node))