Function: icalendar-recur-tz--get-updated-in

icalendar-recur-tz--get-updated-in is a byte-compiled function defined in icalendar-recur.el.gz.

Signature

(icalendar-recur-tz--get-updated-in DT OBS-ONSET OBSERVANCE)

Documentation

Determine how to update DT's zone and dst slots from OBSERVANCE.

DT should be an icalendar-date-time, OBSERVANCE an icalendar-standard or icalendar-daylight, and OBS-ONSET the nearest onset of OBSERVANCE before DT. Returns an icalendar-date-time that can be used to update DT.

In most cases, the return value will contain a zone offset equal to OBSERVANCE's icalendar-tzoffsetto value.

However, when DT falls within a range of nonexistent times after OBS-ONSET, or a range of local times that occur twice (see icalendar-recur-nonexistent-date-time-p and icalendar-recur-date-time-occurs-twice-p), it needs to be interpreted with the UTC offset in effect prior to the OBS-ONSET of OBSERVANCE (see RFC5545 Section 3.3.5). So, for example, at the switch from standard to daylight in New Zealand, 2:30AM NZST (a nonexistent time) becomes 3:30AM NZDT, and at the switch from daylight to standard, 2:30AM (which occurs twice) becomes 1:30AM NZDT, the first occurrence.

Source Code

;; Defined in /usr/src/emacs/lisp/calendar/icalendar-recur.el.gz
(defun icr:tz--get-updated-in (dt obs-onset observance)
  "Determine how to update DT's zone and dst slots from OBSERVANCE.

DT should be an `icalendar-date-time', OBSERVANCE an
`icalendar-standard' or `icalendar-daylight', and OBS-ONSET the nearest
onset of OBSERVANCE before DT.  Returns an `icalendar-date-time' that can
be used to update DT.

In most cases, the return value will contain a zone offset equal to
OBSERVANCE's `icalendar-tzoffsetto' value.

However, when DT falls within a range of nonexistent times after
OBS-ONSET, or a range of local times that occur twice (see
`icalendar-recur-nonexistent-date-time-p' and
`icalendar-recur-date-time-occurs-twice-p'), it needs to be interpreted
with the UTC offset in effect prior to the OBS-ONSET of OBSERVANCE (see
RFC5545 Section 3.3.5).  So, for example, at the switch from standard to
daylight in New Zealand, 2:30AM NZST (a nonexistent time) becomes 3:30AM NZDT,
and at the switch from daylight to standard, 2:30AM (which occurs twice)
becomes 1:30AM NZDT, the first occurrence."
  (ical:with-component observance
      ((ical:tzoffsetfrom :value offset-from)
       (ical:tzoffsetto :value offset-to))
    (let* ((is-daylight (ical:daylight-component-p observance))
           (to-dt (ical:date-time-variant dt :dst is-daylight :zone offset-to))
           (from-dt (ical:date-time-variant dt :dst (not is-daylight)
                                            :zone offset-from))
          updated)
      (cond ((icr:nonexistent-date-time-p to-dt obs-onset observance)
             ;; In this case, RFC5545 requires that we take the same
             ;; point in absolute time as from-dt, but re-decode it into
             ;; to-dt's zone:
             (setq updated (decode-time (encode-time from-dt) offset-to))
             (setf (decoded-time-dst updated) is-daylight))
            ((icr:date-time-occurs-twice-p to-dt obs-onset observance)
             ;; In this case, RFC5545 requires that we interpret dt as
             ;; from-dt, since that is the first occurrence of the clock
             ;; time in the zone:
             (setq updated from-dt))
            (t
             ;; Otherwise we interpret dt as to-dt, i.e., with the
             ;; offset effective within the observance:
             (setq updated to-dt)))
      updated)))