diff options
author | fpi | 2024-09-15 22:01:13 +0200 |
---|---|---|
committer | fpi | 2024-09-15 22:12:07 +0200 |
commit | fb3eccca868d8a797b2a550230743a6e8d5b6510 (patch) | |
tree | ba243c1b223c00fa314b9ab4f6ed23eabddb2b16 | |
parent | Add basic test for VCALENDAR creation (diff) |
Remove VTIMEZONE component
Giving a timezone definiton is not necessary if the event dates are
given in UTC (marked by the "Z" suffix).
This makes event creation significantly easier and could be added back
later based on the TZ environment variable if necessary..
-rw-r--r-- | gnus-icalendar-request-tests.el | 4 | ||||
-rw-r--r-- | gnus-icalendar-request.el | 69 |
2 files changed, 7 insertions, 66 deletions
diff --git a/gnus-icalendar-request-tests.el b/gnus-icalendar-request-tests.el index c7d9751..c9eab69 100644 --- a/gnus-icalendar-request-tests.el +++ b/gnus-icalendar-request-tests.el @@ -53,10 +53,6 @@ END:VEVENT")) (should-not (string-match "^VERSION:" (match-string 1 vcalendar))) (should (string-match "^PRODID:\\(\n\\|.\\)*END:VCALENDAR" vcalendar)) (should-not (string-match "^PRODID:" (match-string 1 vcalendar))) - ;; Ensure we have a timezone entry - (should (string-match "^\\(BEGIN:VTIMEZONE\\(\n\\|.\\)*END:VTIMEZONE\\)" vcalendar)) - (let ((vtimezone (match-string 1 vcalendar))) - ) ;; Ensure the vevent remains intact (should (string-match "^\\(BEGIN:VEVENT\\(\n\\|.\\)*\nEND:VEVENT\\)" vcalendar)) (should (string-match (match-string 1 vcalendar) event))) diff --git a/gnus-icalendar-request.el b/gnus-icalendar-request.el index d57249f..96d52c1 100644 --- a/gnus-icalendar-request.el +++ b/gnus-icalendar-request.el @@ -80,69 +80,14 @@ ;; Vcalendar creation -;; I have not yet found a good way to create vtimezone accurately from -;; scratch. For now hardcoded for CET/CEST and crude general -;; implementation below. -(defvar gnus-icalendar-vtimezone-times - '(CEST "BEGIN:DAYLIGHT -TZOFFSETFROM:+0100 -TZOFFSETTO:+0200 -TZNAME:CEST -DTSTART:19700329T020000 -RRULE:FREQ=YEARLY;BYDAY=-1SU;BYMONTH=3 -END:DAYLIGHT -BEGIN:STANDARD -TZOFFSETFROM:+0200 -TZOFFSETTO:+0100 -TZNAME:CET -DTSTART:19701025T030000 -RRULE:FREQ=YEARLY;BYDAY=-1SU;BYMONTH=10 -END:STANDARD" - CET "BEGIN:DAYLIGHT -TZOFFSETFROM:+0100 -TZOFFSETTO:+0200 -TZNAME:CEST -DTSTART:19700329T020000 -RRULE:FREQ=YEARLY;BYDAY=-1SU;BYMONTH=3 -END:DAYLIGHT -BEGIN:STANDARD -TZOFFSETFROM:+0200 -TZOFFSETTO:+0100 -TZNAME:CET -DTSTART:19701025T030000 -RRULE:FREQ=YEARLY;BYDAY=-1SU;BYMONTH=10 -END:STANDARD") - "Timezone information about standard and daylight savings time used in VCALENDAR parts.") - -(defun gnus-icalendar--default-vtimezone (&optional zone) - "Return default VTIMEZONE information for the current time zone or ZONE if provided." - (let ((time-zone (current-time-zone nil zone))) - (format "BEGIN:STANDARD -DTSTART:%s -TZOFFSETTO:%s -TZOFFSETFROM:+0000 -TZNAME:%s -END:STANDARD" - (format-time-string "%Y%m%dT%H%M%S" 0) ;; set effective timezone start date to epoch - (format-time-string "%z" (current-time) time-zone) ;; time zone offset - (cadr time-zone) - ))) - (defun gnus-icalendar--build-vcalendar-from-vevent (event) "Create VCALENDAR part with VEVENT part EVENT." - (let* ((time-zone (cadr (current-time-zone))) - (vtimezone (mapconcat #'identity `("BEGIN:VTIMEZONE" - ,(format "TZID:%s" time-zone) - ,(or (plist-get gnus-icalendar-vtimezone-times (intern time-zone)) - (gnus-icalendar--default-vtimezone)) - "END:VTIMEZONE") "\n"))) - (mapconcat #'identity `("BEGIN:VCALENDAR" - "PRODID:Gnus" - "VERSION:2.0" - "METHOD:REQUEST" - ,vtimezone - ,event - "END:VCALENDAR") "\n"))) + (mapconcat #'identity `("BEGIN:VCALENDAR" + "PRODID:Gnus" + "VERSION:2.0" + "METHOD:REQUEST" + ,event + "END:VCALENDAR") "\n")) (defun gnus-icalendar-event-message-insert-request (event) "Insert text/calendar part into message with request for VEVENT @@ -172,7 +117,7 @@ or will be asked for if nil. Same for location." (with-temp-buffer (org-time-stamp nil) (buffer-string)))) - (start-time (org-timestamp-to-time + (start-time (org-timestamp-to-time ;; in UTC (org-timestamp-from-string date) nil)) (end-time (org-timestamp-to-time ;; set end-time if input was a time-range (org-timestamp-from-string date) t)) |