aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--lisp/calendar/icalendar.el53
-rw-r--r--test/lisp/calendar/icalendar-tests.el44
2 files changed, 81 insertions, 16 deletions
diff --git a/lisp/calendar/icalendar.el b/lisp/calendar/icalendar.el
index e7ad7383456..2f557f547af 100644
--- a/lisp/calendar/icalendar.el
+++ b/lisp/calendar/icalendar.el
@@ -2389,22 +2389,43 @@ END-T is the event's end time in diary format."
2389 ;; monthly 2389 ;; monthly
2390 ((string-equal frequency "MONTHLY") 2390 ((string-equal frequency "MONTHLY")
2391 (icalendar--dmsg "monthly") 2391 (icalendar--dmsg "monthly")
2392 (setq result 2392 (let* ((byday (cadr (assoc 'BYDAY rrule-props)))
2393 (format 2393 (count-weekday
2394 "%%%%(and (diary-date %s) (diary-block %s %s)) %s%s%s" 2394 (and byday
2395 (let ((day (nth 3 dtstart-dec))) 2395 (save-match-data
2396 (cond ((eq calendar-date-style 'iso) 2396 (when (string-match "\\(-?[0-9]+\\)\\([A-Z][A-Z]\\)"
2397 (format "t t %d" day)) 2397 byday)
2398 ((eq calendar-date-style 'european) 2398 (cons (substring byday
2399 (format "%d t t" day)) 2399 (match-beginning 1)
2400 ((eq calendar-date-style 'american) 2400 (match-end 1))
2401 (format "t %d t" day)))) 2401 (substring byday
2402 dtstart-conv 2402 (match-beginning 2)
2403 (if until 2403 (match-end 2)))))))
2404 until-conv 2404 (rule-part
2405 (if (eq calendar-date-style 'iso) "9999 1 1" "1 1 9999")) ;; FIXME: should be unlimited 2405 (if count-weekday
2406 (or start-t "") 2406 (let ((count (car count-weekday))
2407 (if end-t "-" "") (or end-t "")))) 2407 (weekdaynum (icalendar--get-weekday-number
2408 (cdr count-weekday))))
2409 ;; FIXME: this is valid only for interval==1
2410 (format "(diary-float t %s %s)" weekdaynum count))
2411 (format "(diary-date %s)"
2412 (let ((day (nth 3 dtstart-dec)))
2413 (cond ((eq calendar-date-style 'iso)
2414 (format "t t %d" day))
2415 ((eq calendar-date-style 'european)
2416 (format "%d t t" day))
2417 ((eq calendar-date-style 'american)
2418 (format "t %d t" day))))))))
2419 (setq result
2420 (format
2421 "%%%%(and %s (diary-block %s %s)) %s%s%s"
2422 rule-part
2423 dtstart-conv
2424 (if until
2425 until-conv
2426 (if (eq calendar-date-style 'iso) "9999 1 1" "1 1 9999")) ;; FIXME: should be unlimited
2427 (or start-t "")
2428 (if end-t "-" "") (or end-t "")))))
2408 ;; daily 2429 ;; daily
2409 ((and (string-equal frequency "DAILY")) 2430 ((and (string-equal frequency "DAILY"))
2410 (if until 2431 (if until
diff --git a/test/lisp/calendar/icalendar-tests.el b/test/lisp/calendar/icalendar-tests.el
index 6db4222697e..307d687f2af 100644
--- a/test/lisp/calendar/icalendar-tests.el
+++ b/test/lisp/calendar/icalendar-tests.el
@@ -1257,6 +1257,50 @@ UID:8814e3f9-7482-408f-996c-3bfe486a1263
1257 UID: 8814e3f9-7482-408f-996c-3bfe486a1263 1257 UID: 8814e3f9-7482-408f-996c-3bfe486a1263
1258")) 1258"))
1259 1259
1260(ert-deftest icalendar-import-bug-24199 ()
1261 ;;bug#24199 -- monthly rule with byday-clause
1262 (icalendar-tests--test-import
1263"
1264SUMMARY:Summary
1265DESCRIPTION:Desc
1266LOCATION:Loc
1267DTSTART:20151202T124600
1268DTEND:20151202T160000
1269RRULE:FREQ=MONTHLY;BYDAY=1WE;INTERVAL=1
1270EXDATE:20160106T114600Z
1271EXDATE:20160203T114600Z
1272EXDATE:20160302T114600Z
1273EXDATE:20160504T104600Z
1274EXDATE:20160601T104600Z
1275CLASS:DEFAULT
1276TRANSP:OPAQUE
1277BEGIN:VALARM
1278ACTION:DISPLAY
1279TRIGGER;VALUE=DURATION:-PT3H
1280END:VALARM
1281LAST-MODIFIED:20160805T191040Z
1282UID:9188710a-08a7-4061-bae3-d4cf4972599a
1283"
1284"&%%(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
1285 Desc: Desc
1286 Location: Loc
1287 Class: DEFAULT
1288 UID: 9188710a-08a7-4061-bae3-d4cf4972599a
1289"
1290"&%%(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
1291 Desc: Desc
1292 Location: Loc
1293 Class: DEFAULT
1294 UID: 9188710a-08a7-4061-bae3-d4cf4972599a
1295"
1296"&%%(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
1297 Desc: Desc
1298 Location: Loc
1299 Class: DEFAULT
1300 UID: 9188710a-08a7-4061-bae3-d4cf4972599a
1301"
1302))
1303
1260(ert-deftest icalendar-import-multiple-vcalendars () 1304(ert-deftest icalendar-import-multiple-vcalendars ()
1261 (icalendar-tests--test-import 1305 (icalendar-tests--test-import
1262 "DTSTART;VALUE=DATE:20110723 1306 "DTSTART;VALUE=DATE:20110723