;; monthly
((string-equal frequency "MONTHLY")
(icalendar--dmsg "monthly")
- (setq result
- (format
- "%%%%(and (diary-date %s) (diary-block %s %s)) %s%s%s"
- (let ((day (nth 3 dtstart-dec)))
- (cond ((eq calendar-date-style 'iso)
- (format "t t %d" day))
- ((eq calendar-date-style 'european)
- (format "%d t t" day))
- ((eq calendar-date-style 'american)
- (format "t %d t" day))))
- dtstart-conv
- (if until
- until-conv
- (if (eq calendar-date-style 'iso) "9999 1 1" "1 1 9999")) ;; FIXME: should be unlimited
- (or start-t "")
- (if end-t "-" "") (or end-t ""))))
+ (let* ((byday (cadr (assoc 'BYDAY rrule-props)))
+ (count-weekday
+ (and byday
+ (save-match-data
+ (when (string-match "\\(-?[0-9]+\\)\\([A-Z][A-Z]\\)"
+ byday)
+ (cons (substring byday
+ (match-beginning 1)
+ (match-end 1))
+ (substring byday
+ (match-beginning 2)
+ (match-end 2)))))))
+ (rule-part
+ (if count-weekday
+ (let ((count (car count-weekday))
+ (weekdaynum (icalendar--get-weekday-number
+ (cdr count-weekday))))
+ ;; FIXME: this is valid only for interval==1
+ (format "(diary-float t %s %s)" weekdaynum count))
+ (format "(diary-date %s)"
+ (let ((day (nth 3 dtstart-dec)))
+ (cond ((eq calendar-date-style 'iso)
+ (format "t t %d" day))
+ ((eq calendar-date-style 'european)
+ (format "%d t t" day))
+ ((eq calendar-date-style 'american)
+ (format "t %d t" day))))))))
+ (setq result
+ (format
+ "%%%%(and %s (diary-block %s %s)) %s%s%s"
+ rule-part
+ dtstart-conv
+ (if until
+ until-conv
+ (if (eq calendar-date-style 'iso) "9999 1 1" "1 1 9999")) ;; FIXME: should be unlimited
+ (or start-t "")
+ (if end-t "-" "") (or end-t "")))))
;; daily
((and (string-equal frequency "DAILY"))
(if until
UID: 8814e3f9-7482-408f-996c-3bfe486a1263
"))
+(ert-deftest icalendar-import-bug-24199 ()
+ ;;bug#24199 -- monthly rule with byday-clause
+ (icalendar-tests--test-import
+"
+SUMMARY:Summary
+DESCRIPTION:Desc
+LOCATION:Loc
+DTSTART:20151202T124600
+DTEND:20151202T160000
+RRULE:FREQ=MONTHLY;BYDAY=1WE;INTERVAL=1
+EXDATE:20160106T114600Z
+EXDATE:20160203T114600Z
+EXDATE:20160302T114600Z
+EXDATE:20160504T104600Z
+EXDATE:20160601T104600Z
+CLASS:DEFAULT
+TRANSP:OPAQUE
+BEGIN:VALARM
+ACTION:DISPLAY
+TRIGGER;VALUE=DURATION:-PT3H
+END:VALARM
+LAST-MODIFIED:20160805T191040Z
+UID:9188710a-08a7-4061-bae3-d4cf4972599a
+"
+"&%%(and (not (diary-date 2016 1 6)) (not (diary-date 2016 2 3)) (not (diary-date 2016 3 2)) (not (diary-date 2016 5 4)) (not (diary-date 2016 6 1)) (diary-float t 3 1) (diary-block 2015 12 2 9999 1 1)) 12:46-16:00 Summary
+ Desc: Desc
+ Location: Loc
+ Class: DEFAULT
+ UID: 9188710a-08a7-4061-bae3-d4cf4972599a
+"
+"&%%(and (not (diary-date 6 1 2016)) (not (diary-date 3 2 2016)) (not (diary-date 2 3 2016)) (not (diary-date 4 5 2016)) (not (diary-date 1 6 2016)) (diary-float t 3 1) (diary-block 2 12 2015 1 1 9999)) 12:46-16:00 Summary
+ Desc: Desc
+ Location: Loc
+ Class: DEFAULT
+ UID: 9188710a-08a7-4061-bae3-d4cf4972599a
+"
+"&%%(and (not (diary-date 1 6 2016)) (not (diary-date 2 3 2016)) (not (diary-date 3 2 2016)) (not (diary-date 5 4 2016)) (not (diary-date 6 1 2016)) (diary-float t 3 1) (diary-block 12 2 2015 1 1 9999)) 12:46-16:00 Summary
+ Desc: Desc
+ Location: Loc
+ Class: DEFAULT
+ UID: 9188710a-08a7-4061-bae3-d4cf4972599a
+"
+))
+
(ert-deftest icalendar-import-multiple-vcalendars ()
(icalendar-tests--test-import
"DTSTART;VALUE=DATE:20110723