Function: icalendar--convert-tz-offset
icalendar--convert-tz-offset is a byte-compiled function defined in
icalendar.el.gz.
Signature
(icalendar--convert-tz-offset ALIST DST-P)
Documentation
Return a cons of two strings representing a timezone start.
ALIST is an alist entry from a VTIMEZONE, like STANDARD. DST-P is non-nil if this is for daylight savings time. The strings are suitable for assembling into a TZ variable.
Source Code
;; Defined in /usr/src/emacs/lisp/calendar/icalendar.el.gz
(defun icalendar--convert-tz-offset (alist dst-p)
"Return a cons of two strings representing a timezone start.
ALIST is an alist entry from a VTIMEZONE, like STANDARD.
DST-P is non-nil if this is for daylight savings time.
The strings are suitable for assembling into a TZ variable."
(let* ((offsetto (car (cddr (assq 'TZOFFSETTO alist))))
(offsetfrom (car (cddr (assq 'TZOFFSETFROM alist))))
(rrule-value (car (cddr (assq 'RRULE alist))))
(rdate-p (and (assq 'RDATE alist) t))
(dtstart (car (cddr (assq 'DTSTART alist))))
(no-dst (or rdate-p (equal offsetto offsetfrom))))
;; FIXME: the presence of an RDATE is assumed to denote the first day of the year
(when (and offsetto dtstart (or rrule-value no-dst))
(let* ((rrule (icalendar--split-value rrule-value))
(freq (cadr (assq 'FREQ rrule)))
(bymonth (cadr (assq 'BYMONTH rrule)))
(byday (cadr (assq 'BYDAY rrule))))
;; FIXME: we don't correctly handle WKST here.
(if (or no-dst (and (string= freq "YEARLY") bymonth))
(cons
(concat
;; Fake a name.
(if dst-p "DST" "STD")
;; For TZ, OFFSET is added to the local time. So,
;; invert the values.
(if (eq (aref offsetto 0) ?-) "+" "-")
(substring offsetto 1 3)
":"
(substring offsetto 3 5))
;; The start time.
(let* ((day (if no-dst
1
(icalendar--get-weekday-number (substring byday -2))))
(week (if no-dst
"1"
(if (eq day -1)
byday
(substring byday 0 -2)))))
;; "Translate" the iCalendar way to specify the last
;; (sun|mon|...)day in month to the tzset way.
(if (string= week "-1") ; last day as iCalendar calls it
(setq week "5")) ; last day as tzset calls it
(when no-dst (setq bymonth "1"))
(concat "M" bymonth "." week "." (if (eq day -1) "0"
(int-to-string day))
;; Start time.
"/"
(substring dtstart -6 -4)
":"
(substring dtstart -4 -2)
":"
(substring dtstart -2)))))))))