all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* bug#43669: 28.0.50; [PATCH] Gnus icalendar: fix frequency for weekly events on specific week days
@ 2020-09-28  8:57 Jan Tatarik
  2020-09-28 11:08 ` Lars Ingebrigtsen
  0 siblings, 1 reply; 2+ messages in thread
From: Jan Tatarik @ 2020-09-28  8:57 UTC (permalink / raw)
  To: 43669

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #1: Fix weekly event frequency --]
[-- Type: text/x-diff, Size: 7506 bytes --]

diff --git a/lisp/gnus/gnus-icalendar.el b/lisp/gnus/gnus-icalendar.el
index f624b9d032..7d4fa6c35c 100644
--- a/lisp/gnus/gnus-icalendar.el
+++ b/lisp/gnus/gnus-icalendar.el
@@ -134,11 +134,11 @@ gnus-icalendar-event:recurring-freq
 (cl-defmethod gnus-icalendar-event:recurring-interval ((event gnus-icalendar-event))
   "Return recurring interval of EVENT."
   (let ((rrule (gnus-icalendar-event:recur event))
-        (default-interval 1))
+        (default-interval "1"))
 
-    (string-match "INTERVAL=\\([[:digit:]]+\\)" rrule)
-    (or (match-string 1 rrule)
-        default-interval)))
+    (if (string-match "INTERVAL=\\([[:digit:]]+\\)" rrule)
+        (match-string 1 rrule)
+      default-interval)))
 
 (cl-defmethod gnus-icalendar-event:recurring-days ((event gnus-icalendar-event))
   "Return, when available, the week day numbers on which the EVENT recurs."
diff --git a/test/lisp/gnus/gnus-icalendar-tests.el b/test/lisp/gnus/gnus-icalendar-tests.el
index be23c90af3..dd265b4fa9 100644
--- a/test/lisp/gnus/gnus-icalendar-tests.el
+++ b/test/lisp/gnus/gnus-icalendar-tests.el
@@ -2,7 +2,7 @@
 
 ;; Copyright (C) 2020 Free Software Foundation, Inc.
 
-;; Author: Jan Tatarik <jtatarik@liveintent.com>
+;; Author: Jan Tatarik <jan.tatarik@gmail.com>
 ;; Keywords:
 
 ;; This file is part of GNU Emacs.
@@ -69,7 +69,7 @@ gnus-icalendar-parse
 DTSTART;TZID=America/New_York:20201208T090000
 DTEND;TZID=America/New_York:20201208T100000
 DTSTAMP:20200728T182853Z
-ORGANIZER;CN=Company Events:mailto:liveintent.com_3bm6fh805bme9uoeliqcle1sa
+ORGANIZER;CN=Company Events:mailto:anoncompany.com_3bm6fh805bme9uoeliqcle1sa
  g@group.calendar.google.com
 UID:iipdt88slddpeu7hheuu09sfmd@google.com
 X-MICROSOFT-CDO-OWNERAPPTID:-362490173
@@ -96,7 +96,7 @@ gnus-icalendar-parse
           (should (not (gnus-icalendar-event:recurring-p event)))
           (should (string= (gnus-icalendar-event:start event) "2020-12-08 15:00"))
           (with-slots (organizer summary description location end-time uid rsvp participation-type) event
-                      (should (string= organizer "liveintent.com_3bm6fh805bme9uoeliqcle1sag@group.calendar.google.com"))
+                      (should (string= organizer "anoncompany.com_3bm6fh805bme9uoeliqcle1sag@group.calendar.google.com"))
                       (should (string= summary "Townhall | All Company Meeting"))
                       (should (string= description "In this meeting, we will cover topics from product and engineering presentations and demos to new hire announcements to watching the late"))
                       (should (string= location "New York-22-Town Hall Space (250) [Chrome Box]"))
@@ -182,55 +182,78 @@ gnus-icalendary-byday
 <2020-07-30 15:00-15:30 +1w>")))
       (setenv "TZ" tz))))
 
+(ert-deftest gnus-icalendary-weekly-byday ()
+  ""
+  (let ((tz (getenv "TZ"))
+        (event (gnus-icalendar-tests--get-ical-event "\
+BEGIN:VCALENDAR
+PRODID:-//Google Inc//Google Calendar 70.9054//EN
+VERSION:2.0
+CALSCALE:GREGORIAN
+METHOD:REQUEST
+BEGIN:VTIMEZONE
+TZID:Europe/Berlin
+X-LIC-LOCATION:Europe/Berlin
+BEGIN:DAYLIGHT
+TZOFFSETFROM:+0100
+TZOFFSETTO:+0200
+TZNAME:CEST
+DTSTART:19700329T020000
+RRULE:FREQ=YEARLY;BYMONTH=3;BYDAY=-1SU
+END:DAYLIGHT
+BEGIN:STANDARD
+TZOFFSETFROM:+0200
+TZOFFSETTO:+0100
+TZNAME:CET
+DTSTART:19701025T030000
+RRULE:FREQ=YEARLY;BYMONTH=10;BYDAY=-1SU
+END:STANDARD
+END:VTIMEZONE
+BEGIN:VEVENT
+DTSTART;TZID=Europe/Berlin:20200915T140000
+DTEND;TZID=Europe/Berlin:20200915T143000
+RRULE:FREQ=WEEKLY;BYDAY=FR,MO,TH,TU,WE
+DTSTAMP:20200915T120627Z
+ORGANIZER;CN=anon@anoncompany.com:mailto:anon@anoncompany.com
+UID:7b6g3m7iftuo90ei4ul00feqn_R20200915T120000@google.com
+ATTENDEE;CUTYPE=INDIVIDUAL;ROLE=REQ-PARTICIPANT;PARTSTAT=ACCEPTED;RSVP=TRUE
+ ;CN=participant@anoncompany.com;X-NUM-GUESTS=0:mailto:participant@anoncompany.com
+CREATED:20200325T095723Z
+DESCRIPTION:Coffee talk
+LAST-MODIFIED:20200915T120623Z
+LOCATION:
+SEQUENCE:0
+STATUS:CONFIRMED
+SUMMARY:Casual coffee talk
+TRANSP:OPAQUE
+END:VEVENT
+END:VCALENDAR" (list "participant@anoncompany.com"))))
 
-;; (VCALENDAR nil
-;; 	   ((PRODID nil "Zimbra-Calendar-Provider")
-;; 	    (VERSION nil "2.0")
-;; 	    (METHOD nil "REQUEST"))
-;; 	   ((VTIMEZONE nil
-;; 		       ((TZID nil "America/New_York"))
-;; 		       ((STANDARD nil
-;; 				  ((DTSTART nil "16010101T020000")
-;; 				   (TZOFFSETTO nil "-0500")
-;; 				   (TZOFFSETFROM nil "-0400")
-;; 				   (RRULE nil "FREQ=YEARLY;WKST=MO;INTERVAL=1;BYMONTH=11;BYDAY=1SU")
-;; 				   (TZNAME nil "EST"))
-;; 				  nil)
-;; 			(DAYLIGHT nil
-;; 				  ((DTSTART nil "16010101T020000")
-;; 				   (TZOFFSETTO nil "-0400")
-;; 				   (TZOFFSETFROM nil "-0500")
-;; 				   (RRULE nil "FREQ=YEARLY;WKST=MO;INTERVAL=1;BYMONTH=3;BYDAY=2SU")
-;; 				   (TZNAME nil "EDT"))
-;; 				  nil)))
-;; 	    (VEVENT nil
-;; 		    ((UID nil "903a5415-9067-4f63-b499-1b6205f49c88")
-;; 		     (RRULE nil "FREQ=DAILY;UNTIL=20200825T035959Z;INTERVAL=1;BYDAY=MO,TU,WE,TH,FR")
-;; 		     (SUMMARY nil "appointment every weekday, start jul 24, 2020, end aug 24, 2020")
-;; 		     (ATTENDEE
-;; 		      (CN "Mark Hershberger" ROLE "REQ-PARTICIPANT" PARTSTAT "NEEDS-ACTION" CN "Mark A. Hershberger")
-;; 		      "mailto:mah <at> nichework.com")
-;; 		     (DTSTART
-;; 		      (TZID "America/New_York")
-;; 		      "20200724T090000")
-;; 		     (DTEND
-;; 		      (TZID "America/New_York")
-;; 		      "20200724T093000")
-;; 		     (STATUS nil "CONFIRMED")
-;; 		     (CLASS nil "PUBLIC")
-;; 		     (X-MICROSOFT-CDO-INTENDEDSTATUS nil "BUSY")
-;; 		     (TRANSP nil "OPAQUE")
-;; 		     (LAST-MODIFIED nil "20200719T150815Z")
-;; 		     (DTSTAMP nil "20200719T150815Z")
-;; 		     (SEQUENCE nil "0")
-;; 		     (DESCRIPTION nil "The following is a new meeting request:"))
-;; 		    ((VALARM nil
-;; 			     ((ACTION nil "DISPLAY")
-;; 			      (TRIGGER
-;; 			       (RELATED "START")
-;; 			       "-PT5M")
-;; 			      (DESCRIPTION nil "Reminder"))
-;; 			     nil)))))
+    (unwind-protect
+        (progn
+          ;; Use this form so as not to rely on system tz database.
+	  ;; Eg hydra.nixos.org.
+          (setenv "TZ" "CET-1CEST,M3.5.0/2,M10.5.0/3")
+          (should (eq (eieio-object-class event) 'gnus-icalendar-event-request))
+          (should (gnus-icalendar-event:recurring-p event))
+          (should (string= (gnus-icalendar-event:recurring-interval event) "1"))
+          (should (string= (gnus-icalendar-event:start event) "2020-09-15 14:00"))
+          (with-slots (organizer summary description location end-time uid rsvp participation-type) event
+            (should (string= organizer "anon@anoncompany.com"))
+            (should (string= summary "Casual coffee talk"))
+            (should (string= description "Coffee talk"))
+            (should (string= location ""))
+            (should (string= (format-time-string "%Y-%m-%d %H:%M" end-time) "2020-09-15 14:30"))
+            (should (string= uid "7b6g3m7iftuo90ei4ul00feqn_R20200915T120000@google.com"))
+            (should rsvp)
+            (should (eq participation-type 'required)))
+          (should (equal (sort (gnus-icalendar-event:recurring-days event) #'<) '(1 2 3 4 5)))
+          (should (string= (gnus-icalendar-event:org-timestamp event) "<2020-09-15 14:00-14:30 +1w>
+<2020-09-16 14:00-14:30 +1w>
+<2020-09-17 14:00-14:30 +1w>
+<2020-09-18 14:00-14:30 +1w>
+<2020-09-21 14:00-14:30 +1w>")))
+      (setenv "TZ" tz))))
 
 (provide 'gnus-icalendar-tests)
 ;;; gnus-icalendar-tests.el ends here

[-- Attachment #2: Type: text/plain, Size: 470 bytes --]


Attached is a fix for gnus-icalendar handling of weekly calendar events
that are scheduled on specific week days.

Example: in the absence of explicit INTERVAL value in the calendar
event, a weekly event with occurrences scheduled for Mondays and
Wednesdays should receive the default recurring interval of "1" and the
org mode timestamp repeater should be "+1w".

Due to a bug in the current code we receive "WEEKLY" and "+WEEKLYw"
instead. The patch fixes the issue.

^ permalink raw reply related	[flat|nested] 2+ messages in thread

* bug#43669: 28.0.50; [PATCH] Gnus icalendar: fix frequency for weekly events on specific week days
  2020-09-28  8:57 bug#43669: 28.0.50; [PATCH] Gnus icalendar: fix frequency for weekly events on specific week days Jan Tatarik
@ 2020-09-28 11:08 ` Lars Ingebrigtsen
  0 siblings, 0 replies; 2+ messages in thread
From: Lars Ingebrigtsen @ 2020-09-28 11:08 UTC (permalink / raw)
  To: Jan Tatarik; +Cc: 43669

Jan Tatarik <jan.tatarik@gmail.com> writes:

> Due to a bug in the current code we receive "WEEKLY" and "+WEEKLYw"
> instead. The patch fixes the issue.

Thanks; applied to Emacs 28.

-- 
(domestic pets only, the antidote for overdose, milk.)
   bloggy blog: http://lars.ingebrigtsen.no





^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2020-09-28 11:08 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2020-09-28  8:57 bug#43669: 28.0.50; [PATCH] Gnus icalendar: fix frequency for weekly events on specific week days Jan Tatarik
2020-09-28 11:08 ` Lars Ingebrigtsen

Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.