]> code.delx.au - gnu-emacs/blob - test/automated/icalendar-tests.el
Merge from emacs-24; up to 2014-06-26T06:55:15Z!rgm@gnu.org
[gnu-emacs] / test / automated / icalendar-tests.el
1 ;; icalendar-tests.el --- Test suite for icalendar.el
2
3 ;; Copyright (C) 2005, 2008-2014 Free Software Foundation, Inc.
4
5 ;; Author: Ulf Jasper <ulf.jasper@web.de>
6 ;; Created: March 2005
7 ;; Keywords: calendar
8 ;; Human-Keywords: calendar, diary, iCalendar, vCalendar
9
10 ;; This file is part of GNU Emacs.
11
12 ;; GNU Emacs is free software: you can redistribute it and/or modify
13 ;; it under the terms of the GNU General Public License as published by
14 ;; the Free Software Foundation, either version 3 of the License, or
15 ;; (at your option) any later version.
16
17 ;; GNU Emacs is distributed in the hope that it will be useful,
18 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
19 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20 ;; GNU General Public License for more details.
21
22 ;; You should have received a copy of the GNU General Public License
23 ;; along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>.
24
25 ;;; Commentary:
26
27 ;; TODO:
28 ;; - Add more unit tests for functions, timezone etc.
29
30 ;; Note: Watch the trailing blank that is added on import.
31
32 ;;; Code:
33
34 (require 'ert)
35 (require 'icalendar)
36
37 ;; ======================================================================
38 ;; Helpers
39 ;; ======================================================================
40
41 (defun icalendar-tests--get-ical-event (ical-string)
42 "Return iCalendar event for ICAL-STRING."
43 (save-excursion
44 (with-temp-buffer
45 (insert ical-string)
46 (goto-char (point-min))
47 (car (icalendar--read-element nil nil)))))
48
49 (defun icalendar-tests--trim (string)
50 "Remove leading and trailing whitespace from STRING."
51 (replace-regexp-in-string "[ \t\n]+\\'" ""
52 (replace-regexp-in-string "\\`[ \t\n]+" "" string)))
53
54 ;; ======================================================================
55 ;; Tests of functions
56 ;; ======================================================================
57
58 (ert-deftest icalendar--create-uid ()
59 "Test for `icalendar--create-uid'."
60 (let* ((icalendar-uid-format "xxx-%t-%c-%h-%u-%s")
61 t-ct
62 (icalendar--uid-count 77)
63 (entry-full "30.06.1964 07:01 blahblah")
64 (hash (format "%d" (abs (sxhash entry-full))))
65 (contents "DTSTART:19640630T070100\nblahblah")
66 (username (or user-login-name "UNKNOWN_USER"))
67 )
68 (fset 't-ct (symbol-function 'current-time))
69 (unwind-protect
70 (progn
71 (fset 'current-time (lambda () '(1 2 3)))
72 (should (= 77 icalendar--uid-count))
73 (should (string= (concat "xxx-123-77-" hash "-" username "-19640630")
74 (icalendar--create-uid entry-full contents)))
75 (should (= 78 icalendar--uid-count)))
76 ;; restore 'current-time
77 (fset 'current-time (symbol-function 't-ct)))
78 (setq contents "blahblah")
79 (setq icalendar-uid-format "yyy%syyy")
80 (should (string= (concat "yyyDTSTARTyyy")
81 (icalendar--create-uid entry-full contents)))))
82
83 (ert-deftest icalendar--calendar-style ()
84 "Test for `icalendar--date-style'."
85 (dolist (calendar-date-style '(iso american european))
86 (should (eq (icalendar--date-style) calendar-date-style)))
87 (let ((cds calendar-date-style)
88 (european-calendar-style t))
89 (makunbound 'calendar-date-style)
90 (should (eq (icalendar--date-style) 'european))
91 (with-no-warnings (setq european-calendar-style nil)) ;still get warning!?! FIXME
92 (should (eq (icalendar--date-style) 'american))
93 (setq calendar-date-style cds)))
94
95 (ert-deftest icalendar-convert-anniversary-to-ical ()
96 "Test method for `icalendar--convert-anniversary-to-ical'."
97 (let* ((calendar-date-style 'iso)
98 result)
99 (setq result (icalendar--convert-anniversary-to-ical
100 "" "%%(diary-anniversary 1964 6 30) g"))
101 (should (= 2 (length result)))
102 (should (string= (concat
103 "\nDTSTART;VALUE=DATE:19640630"
104 "\nDTEND;VALUE=DATE:19640701"
105 "\nRRULE:FREQ=YEARLY;INTERVAL=1;BYMONTH=06;BYMONTHDAY=30")
106 (car result)))
107 (should (string= "g" (cadr result)))))
108
109 (ert-deftest icalendar--convert-cyclic-to-ical ()
110 "Test method for `icalendar--convert-cyclic-to-ical'."
111 (let* ((calendar-date-style 'iso)
112 result)
113 (setq result (icalendar--convert-block-to-ical
114 "" "%%(diary-block 2004 7 19 2004 8 27) Sommerferien"))
115 (should (= 2 (length result)))
116 (should (string= (concat
117 "\nDTSTART;VALUE=DATE:20040719"
118 "\nDTEND;VALUE=DATE:20040828")
119 (car result)))
120 (should (string= "Sommerferien" (cadr result)))))
121
122 (ert-deftest icalendar--convert-block-to-ical ()
123 "Test method for `icalendar--convert-block-to-ical'."
124 (let* ((calendar-date-style 'iso)
125 result)
126 (setq result (icalendar--convert-block-to-ical
127 "" "%%(diary-block 2004 7 19 2004 8 27) Sommerferien"))
128 (should (= 2 (length result)))
129 (should (string= (concat
130 "\nDTSTART;VALUE=DATE:20040719"
131 "\nDTEND;VALUE=DATE:20040828")
132 (car result)))
133 (should (string= "Sommerferien" (cadr result)))))
134
135 (ert-deftest icalendar--convert-yearly-to-ical ()
136 "Test method for `icalendar--convert-yearly-to-ical'."
137 (let* ((calendar-date-style 'iso)
138 result
139 (calendar-month-name-array
140 ["January" "February" "March" "April" "May" "June" "July" "August"
141 "September" "October" "November" "December"]))
142 (setq result (icalendar--convert-yearly-to-ical "" "May 1 Tag der Arbeit"))
143 (should (= 2 (length result)))
144 (should (string= (concat
145 "\nDTSTART;VALUE=DATE:19000501"
146 "\nDTEND;VALUE=DATE:19000502"
147 "\nRRULE:FREQ=YEARLY;INTERVAL=1;BYMONTH=5;BYMONTHDAY=1")
148 (car result)))
149 (should (string= "Tag der Arbeit" (cadr result)))))
150
151 (ert-deftest icalendar--convert-weekly-to-ical ()
152 "Test method for `icalendar--convert-weekly-to-ical'."
153 (let* ((calendar-date-style 'iso)
154 result
155 (calendar-day-name-array
156 ["Sunday" "Monday" "Tuesday" "Wednesday" "Thursday" "Friday"
157 "Saturday"]))
158 (setq result (icalendar--convert-weekly-to-ical "" "Monday 8:30 subject"))
159 (should (= 2 (length result)))
160 (should (string= (concat "\nDTSTART;VALUE=DATE-TIME:20050103T083000"
161 "\nDTEND;VALUE=DATE-TIME:20050103T093000"
162 "\nRRULE:FREQ=WEEKLY;INTERVAL=1;BYDAY=MO")
163 (car result)))
164 (should (string= "subject" (cadr result)))))
165
166 (ert-deftest icalendar--parse-vtimezone ()
167 "Test method for `icalendar--parse-vtimezone'."
168 (let (vtimezone result)
169 (setq vtimezone (icalendar-tests--get-ical-event "BEGIN:VTIMEZONE
170 TZID:thename
171 BEGIN:STANDARD
172 DTSTART:16010101T040000
173 TZOFFSETFROM:+0300
174 TZOFFSETTO:+0200
175 RRULE:FREQ=YEARLY;INTERVAL=1;BYDAY=-1SU;BYMONTH=10
176 END:STANDARD
177 BEGIN:DAYLIGHT
178 DTSTART:16010101T030000
179 TZOFFSETFROM:+0200
180 TZOFFSETTO:+0300
181 RRULE:FREQ=YEARLY;INTERVAL=1;BYDAY=-1SU;BYMONTH=3
182 END:DAYLIGHT
183 END:VTIMEZONE
184 "))
185 (setq result (icalendar--parse-vtimezone vtimezone))
186 (should (string= "thename" (car result)))
187 (message (cdr result))
188 (should (string= "STD-02:00DST-03:00,M3.5.0/03:00:00,M10.5.0/04:00:00"
189 (cdr result)))
190 (setq vtimezone (icalendar-tests--get-ical-event "BEGIN:VTIMEZONE
191 TZID:anothername\, with a comma
192 BEGIN:STANDARD
193 DTSTART:16010101T040000
194 TZOFFSETFROM:+0300
195 TZOFFSETTO:+0200
196 RRULE:FREQ=YEARLY;INTERVAL=1;BYDAY=2MO;BYMONTH=10
197 END:STANDARD
198 BEGIN:DAYLIGHT
199 DTSTART:16010101T030000
200 TZOFFSETFROM:+0200
201 TZOFFSETTO:+0300
202 RRULE:FREQ=YEARLY;INTERVAL=1;BYDAY=2MO;BYMONTH=3
203 END:DAYLIGHT
204 END:VTIMEZONE
205 "))
206 (setq result (icalendar--parse-vtimezone vtimezone))
207 (should (string= "anothername, with a comma" (car result)))
208 (message (cdr result))
209 (should (string= "STD-02:00DST-03:00,M3.2.1/03:00:00,M10.2.1/04:00:00"
210 (cdr result)))))
211
212 (ert-deftest icalendar--convert-ordinary-to-ical ()
213 "Test method for `icalendar--convert-ordinary-to-ical'."
214 (let* ((calendar-date-style 'iso)
215 result)
216 ;; without time
217 (setq result (icalendar--convert-ordinary-to-ical "&?" "2010 2 15 subject"))
218 (should (= 2 (length result)))
219 (should (string= "\nDTSTART;VALUE=DATE:20100215\nDTEND;VALUE=DATE:20100216"
220 (car result)))
221 (should (string= "subject" (cadr result)))
222
223 ;; with time
224 (setq result (icalendar--convert-ordinary-to-ical
225 "&?" "&2010 2 15 12:34-23:45 s"))
226 (should (= 2 (length result)))
227 (should (string= (concat "\nDTSTART;VALUE=DATE-TIME:20100215T123400"
228 "\nDTEND;VALUE=DATE-TIME:20100215T234500")
229 (car result)))
230 (should (string= "s" (cadr result)))
231
232 ;; with time, again -- test bug#5549
233 (setq result (icalendar--convert-ordinary-to-ical
234 "x?" "x2010 2 15 0:34-1:45 s"))
235 (should (= 2 (length result)))
236 (should (string= (concat "\nDTSTART;VALUE=DATE-TIME:20100215T003400"
237 "\nDTEND;VALUE=DATE-TIME:20100215T014500")
238 (car result)))
239 (should (string= "s" (cadr result)))))
240
241 (ert-deftest icalendar--diarytime-to-isotime ()
242 "Test method for `icalendar--diarytime-to-isotime'."
243 (should (string= "T011500"
244 (icalendar--diarytime-to-isotime "01:15" "")))
245 (should (string= "T011500"
246 (icalendar--diarytime-to-isotime "1:15" "")))
247 (should (string= "T000100"
248 (icalendar--diarytime-to-isotime "0:01" "")))
249 (should (string= "T010000"
250 (icalendar--diarytime-to-isotime "0100" "")))
251 (should (string= "T010000"
252 (icalendar--diarytime-to-isotime "0100" "am")))
253 (should (string= "T130000"
254 (icalendar--diarytime-to-isotime "0100" "pm")))
255 (should (string= "T120000"
256 (icalendar--diarytime-to-isotime "1200" "")))
257 (should (string= "T171700"
258 (icalendar--diarytime-to-isotime "17:17" "")))
259 (should (string= "T000000"
260 (icalendar--diarytime-to-isotime "1200" "am")))
261 (should (string= "T000100"
262 (icalendar--diarytime-to-isotime "1201" "am")))
263 (should (string= "T005900"
264 (icalendar--diarytime-to-isotime "1259" "am")))
265 (should (string= "T120000"
266 (icalendar--diarytime-to-isotime "1200" "pm")))
267 (should (string= "T120100"
268 (icalendar--diarytime-to-isotime "1201" "pm")))
269 (should (string= "T125900"
270 (icalendar--diarytime-to-isotime "1259" "pm"))))
271
272 (ert-deftest icalendar--datetime-to-diary-date ()
273 "Test method for `icalendar--datetime-to-diary-date'."
274 (let* ((datetime '(59 59 23 31 12 2008))
275 (calendar-date-style 'iso))
276 (should (string= "2008 12 31"
277 (icalendar--datetime-to-diary-date datetime)))
278 (setq calendar-date-style 'european)
279 (should (string= "31 12 2008"
280 (icalendar--datetime-to-diary-date datetime)))
281 (setq calendar-date-style 'american)
282 (should (string= "12 31 2008"
283 (icalendar--datetime-to-diary-date datetime)))))
284
285 (ert-deftest icalendar--datestring-to-isodate ()
286 "Test method for `icalendar--datestring-to-isodate'."
287 (let ((calendar-date-style 'iso))
288 ;; numeric iso
289 (should (string= "20080511"
290 (icalendar--datestring-to-isodate "2008 05 11")))
291 (should (string= "20080531"
292 (icalendar--datestring-to-isodate "2008 05 31")))
293 (should (string= "20080602"
294 (icalendar--datestring-to-isodate "2008 05 31" 2)))
295
296 ;; numeric european
297 (setq calendar-date-style 'european)
298 (should (string= "20080511"
299 (icalendar--datestring-to-isodate "11 05 2008")))
300 (should (string= "20080531"
301 (icalendar--datestring-to-isodate "31 05 2008")))
302 (should (string= "20080602"
303 (icalendar--datestring-to-isodate "31 05 2008" 2)))
304
305 ;; numeric american
306 (setq calendar-date-style 'american)
307 (should (string= "20081105"
308 (icalendar--datestring-to-isodate "11 05 2008")))
309 (should (string= "20081230"
310 (icalendar--datestring-to-isodate "12 30 2008")))
311 (should (string= "20090101"
312 (icalendar--datestring-to-isodate "12 30 2008" 2)))
313
314 ;; non-numeric
315 (setq calendar-date-style nil) ;not necessary for conversion
316 (should (string= "20081105"
317 (icalendar--datestring-to-isodate "Nov 05 2008")))
318 (should (string= "20081105"
319 (icalendar--datestring-to-isodate "05 Nov 2008")))
320 (should (string= "20081105"
321 (icalendar--datestring-to-isodate "2008 Nov 05")))))
322
323 (ert-deftest icalendar--first-weekday-of-year ()
324 "Test method for `icalendar-first-weekday-of-year'."
325 (should (eq 1 (icalendar-first-weekday-of-year "TU" 2008)))
326 (should (eq 3 (icalendar-first-weekday-of-year "WE" 2007)))
327 (should (eq 5 (icalendar-first-weekday-of-year "TH" 2006)))
328 (should (eq 7 (icalendar-first-weekday-of-year "FR" 2005)))
329 (should (eq 3 (icalendar-first-weekday-of-year "SA" 2004)))
330 (should (eq 5 (icalendar-first-weekday-of-year "SU" 2003)))
331 (should (eq 7 (icalendar-first-weekday-of-year "MO" 2002)))
332 (should (eq 3 (icalendar-first-weekday-of-year "MO" 2000)))
333 (should (eq 1 (icalendar-first-weekday-of-year "TH" 1970))))
334
335 (ert-deftest icalendar--import-format-sample ()
336 "Test method for `icalendar-import-format-sample'."
337 (should (string= (concat "SUMMARY=`a' DESCRIPTION=`b' LOCATION=`c' "
338 "ORGANIZER=`d' STATUS=`' URL=`' CLASS=`'")
339 (icalendar-import-format-sample
340 (icalendar-tests--get-ical-event "BEGIN:VEVENT
341 DTSTAMP:20030509T043439Z
342 DTSTART:20030509T103000
343 SUMMARY:a
344 ORGANIZER:d
345 LOCATION:c
346 DTEND:20030509T153000
347 DESCRIPTION:b
348 END:VEVENT
349 ")))))
350
351 (ert-deftest icalendar--format-ical-event ()
352 "Test `icalendar--format-ical-event'."
353 (let ((icalendar-import-format "%s%d%l%o%t%u%c")
354 (icalendar-import-format-summary "SUM %s")
355 (icalendar-import-format-location " LOC %s")
356 (icalendar-import-format-description " DES %s")
357 (icalendar-import-format-organizer " ORG %s")
358 (icalendar-import-format-status " STA %s")
359 (icalendar-import-format-url " URL %s")
360 (icalendar-import-format-class " CLA %s")
361 (event (icalendar-tests--get-ical-event "BEGIN:VEVENT
362 DTSTAMP:20030509T043439Z
363 DTSTART:20030509T103000
364 SUMMARY:sum
365 ORGANIZER:org
366 LOCATION:loc
367 DTEND:20030509T153000
368 DESCRIPTION:des
369 END:VEVENT
370 ")))
371 (should (string= "SUM sum DES des LOC loc ORG org"
372 (icalendar--format-ical-event event)))
373 (setq icalendar-import-format (lambda (&rest ignore)
374 "helloworld"))
375 (should (string= "helloworld" (icalendar--format-ical-event event)))
376 (setq icalendar-import-format
377 (lambda (e)
378 (format "-%s-%s-%s-%s-%s-%s-%s-"
379 (icalendar--get-event-property event 'SUMMARY)
380 (icalendar--get-event-property event 'DESCRIPTION)
381 (icalendar--get-event-property event 'LOCATION)
382 (icalendar--get-event-property event 'ORGANIZER)
383 (icalendar--get-event-property event 'STATUS)
384 (icalendar--get-event-property event 'URL)
385 (icalendar--get-event-property event 'CLASS))))
386 (should (string= "-sum-des-loc-org-nil-nil-nil-"
387 (icalendar--format-ical-event event)))))
388
389 (ert-deftest icalendar--parse-summary-and-rest ()
390 "Test `icalendar--parse-summary-and-rest'."
391 (let ((icalendar-import-format "%s%d%l%o%t%u%c")
392 (icalendar-import-format-summary "SUM %s")
393 (icalendar-import-format-location " LOC %s")
394 (icalendar-import-format-description " DES %s")
395 (icalendar-import-format-organizer " ORG %s")
396 (icalendar-import-format-status " STA %s")
397 (icalendar-import-format-url " URL %s")
398 (icalendar-import-format-class " CLA %s")
399 (result))
400 (setq result (icalendar--parse-summary-and-rest "SUM sum ORG org"))
401 (should (string= "org" (cdr (assoc 'org result))))
402
403 (setq result (icalendar--parse-summary-and-rest
404 "SUM sum DES des LOC loc ORG org STA sta URL url CLA cla"))
405 (should (string= "des" (cdr (assoc 'des result))))
406 (should (string= "loc" (cdr (assoc 'loc result))))
407 (should (string= "org" (cdr (assoc 'org result))))
408 (should (string= "sta" (cdr (assoc 'sta result))))
409 (should (string= "cla" (cdr (assoc 'cla result))))
410
411 (setq icalendar-import-format (lambda () "Hello world"))
412 (setq result (icalendar--parse-summary-and-rest
413 "blah blah "))
414 (should (not result))
415 ))
416
417 ;; ======================================================================
418 ;; Export tests
419 ;; ======================================================================
420
421 (defun icalendar-tests--test-export (input-iso input-european input-american
422 expected-output)
423 "Perform an export test.
424 Argument INPUT-ISO iso style diary string.
425 Argument INPUT-EUROPEAN european style diary string.
426 Argument INPUT-AMERICAN american style diary string.
427 Argument EXPECTED-OUTPUT expected iCalendar result string.
428
429 European style input data must use german month names. American
430 and ISO style input data must use english month names."
431 (let ((tz (getenv "TZ"))
432 (calendar-date-style 'iso)
433 (icalendar-recurring-start-year 2000))
434 (unwind-protect
435 (progn
436 ;;; (message "Current time zone: %s" (current-time-zone))
437 ;; Use this form so as not to rely on system tz database.
438 ;; Eg hydra.nixos.org.
439 (setenv "TZ" "CET-1CEST,M3.5.0/2,M10.5.0/3")
440 ;;; (message "Current time zone: %s" (current-time-zone))
441 (when input-iso
442 (let ((calendar-month-name-array
443 ["January" "February" "March" "April" "May" "June" "July" "August"
444 "September" "October" "November" "December"])
445 (calendar-day-name-array
446 ["Sunday" "Monday" "Tuesday" "Wednesday" "Thursday" "Friday"
447 "Saturday"]))
448 (setq calendar-date-style 'iso)
449 (icalendar-tests--do-test-export input-iso expected-output)))
450 (when input-european
451 (let ((calendar-month-name-array
452 ["Januar" "Februar" "März" "April" "Mai" "Juni" "Juli" "August"
453 "September" "Oktober" "November" "Dezember"])
454 (calendar-day-name-array
455 ["Sonntag" "Montag" "Dienstag" "Mittwoch" "Donnerstag" "Freitag"
456 "Samstag"]))
457 (setq calendar-date-style 'european)
458 (icalendar-tests--do-test-export input-european expected-output)))
459 (when input-american
460 (let ((calendar-month-name-array
461 ["January" "February" "March" "April" "May" "June" "July" "August"
462 "September" "October" "November" "December"])
463 (calendar-day-name-array
464 ["Sunday" "Monday" "Tuesday" "Wednesday" "Thursday" "Friday"
465 "Saturday"]))
466 (setq calendar-date-style 'american)
467 (icalendar-tests--do-test-export input-american expected-output))))
468 ;; restore time-zone even if something went terribly wrong
469 (setenv "TZ" tz))))
470
471 (defun icalendar-tests--do-test-export (input expected-output)
472 "Actually perform export test.
473 Argument INPUT input diary string.
474 Argument EXPECTED-OUTPUT expected iCalendar result string."
475 (let ((temp-file (make-temp-file "icalendar-tests-ics")))
476 (unwind-protect
477 (progn
478 (with-temp-buffer
479 (insert input)
480 (icalendar-export-region (point-min) (point-max) temp-file))
481 (save-excursion
482 (find-file temp-file)
483 (goto-char (point-min))
484 (cond (expected-output
485 (should (re-search-forward "^\\s-*BEGIN:VCALENDAR
486 PRODID:-//Emacs//NONSGML icalendar.el//EN
487 VERSION:2.0
488 BEGIN:VEVENT
489 UID:emacs[0-9]+
490 \\(\\(.\\|\n\\)+\\)
491 END:VEVENT
492 END:VCALENDAR
493 \\s-*$"
494 nil t))
495 (should (string-match
496 (concat "^\\s-*"
497 (regexp-quote (buffer-substring-no-properties
498 (match-beginning 1) (match-end 1)))
499 "\\s-*$")
500 expected-output)))
501 (t
502 (should (re-search-forward "^\\s-*BEGIN:VCALENDAR
503 PRODID:-//Emacs//NONSGML icalendar.el//EN
504 VERSION:2.0
505 END:VCALENDAR
506 \\s-*$"
507 nil t))))))
508 ;; cleanup!!
509 (kill-buffer (find-buffer-visiting temp-file))
510 (delete-file temp-file))))
511
512 (ert-deftest icalendar-export-ordinary-no-time ()
513 "Perform export test."
514
515 (let ((icalendar-export-hidden-diary-entries nil))
516 (icalendar-tests--test-export
517 "&2000 Oct 3 ordinary no time "
518 "&3 Okt 2000 ordinary no time "
519 "&Oct 3 2000 ordinary no time "
520 nil))
521
522 (icalendar-tests--test-export
523 "2000 Oct 3 ordinary no time "
524 "3 Okt 2000 ordinary no time "
525 "Oct 3 2000 ordinary no time "
526 "DTSTART;VALUE=DATE:20001003
527 DTEND;VALUE=DATE:20001004
528 SUMMARY:ordinary no time
529 "))
530
531 (ert-deftest icalendar-export-ordinary ()
532 "Perform export test."
533
534 (icalendar-tests--test-export
535 "2000 Oct 3 16:30 ordinary with time"
536 "3 Okt 2000 16:30 ordinary with time"
537 "Oct 3 2000 16:30 ordinary with time"
538 "DTSTART;VALUE=DATE-TIME:20001003T163000
539 DTEND;VALUE=DATE-TIME:20001003T173000
540 SUMMARY:ordinary with time
541 ")
542 (icalendar-tests--test-export
543 "2000 10 3 16:30 ordinary with time 2"
544 "3 10 2000 16:30 ordinary with time 2"
545 "10 3 2000 16:30 ordinary with time 2"
546 "DTSTART;VALUE=DATE-TIME:20001003T163000
547 DTEND;VALUE=DATE-TIME:20001003T173000
548 SUMMARY:ordinary with time 2
549 ")
550
551 (icalendar-tests--test-export
552 "2000/10/3 16:30 ordinary with time 3"
553 "3/10/2000 16:30 ordinary with time 3"
554 "10/3/2000 16:30 ordinary with time 3"
555 "DTSTART;VALUE=DATE-TIME:20001003T163000
556 DTEND;VALUE=DATE-TIME:20001003T173000
557 SUMMARY:ordinary with time 3
558 "))
559
560 (ert-deftest icalendar-export-multiline ()
561 "Perform export test."
562
563 ;; multiline -- FIXME!!!
564 (icalendar-tests--test-export
565 "2000 October 3 16:30 multiline
566 17:30 multiline continued FIXME"
567 "3 Oktober 2000 16:30 multiline
568 17:30 multiline continued FIXME"
569 "October 3 2000 16:30 multiline
570 17:30 multiline continued FIXME"
571 "DTSTART;VALUE=DATE-TIME:20001003T163000
572 DTEND;VALUE=DATE-TIME:20001003T173000
573 SUMMARY:multiline
574 DESCRIPTION:
575 17:30 multiline continued FIXME
576 "))
577
578 (ert-deftest icalendar-export-weekly-by-day ()
579 "Perform export test."
580
581 ;; weekly by day
582 (icalendar-tests--test-export
583 "Monday 1:30pm weekly by day with start time"
584 "Montag 13:30 weekly by day with start time"
585 "Monday 1:30pm weekly by day with start time"
586 "DTSTART;VALUE=DATE-TIME:20000103T133000
587 DTEND;VALUE=DATE-TIME:20000103T143000
588 RRULE:FREQ=WEEKLY;INTERVAL=1;BYDAY=MO
589 SUMMARY:weekly by day with start time
590 ")
591
592 (icalendar-tests--test-export
593 "Monday 13:30-15:00 weekly by day with start and end time"
594 "Montag 13:30-15:00 weekly by day with start and end time"
595 "Monday 01:30pm-03:00pm weekly by day with start and end time"
596 "DTSTART;VALUE=DATE-TIME:20000103T133000
597 DTEND;VALUE=DATE-TIME:20000103T150000
598 RRULE:FREQ=WEEKLY;INTERVAL=1;BYDAY=MO
599 SUMMARY:weekly by day with start and end time
600 "))
601
602 (ert-deftest icalendar-export-yearly ()
603 "Perform export test."
604 ;; yearly
605 (icalendar-tests--test-export
606 "may 1 yearly no time"
607 "1 Mai yearly no time"
608 "may 1 yearly no time"
609 "DTSTART;VALUE=DATE:19000501
610 DTEND;VALUE=DATE:19000502
611 RRULE:FREQ=YEARLY;INTERVAL=1;BYMONTH=5;BYMONTHDAY=1
612 SUMMARY:yearly no time
613 "))
614
615 (ert-deftest icalendar-export-anniversary ()
616 "Perform export test."
617 ;; anniversaries
618 (icalendar-tests--test-export
619 "%%(diary-anniversary 1989 10 3) anniversary no time"
620 "%%(diary-anniversary 3 10 1989) anniversary no time"
621 "%%(diary-anniversary 10 3 1989) anniversary no time"
622 "DTSTART;VALUE=DATE:19891003
623 DTEND;VALUE=DATE:19891004
624 RRULE:FREQ=YEARLY;INTERVAL=1;BYMONTH=10;BYMONTHDAY=03
625 SUMMARY:anniversary no time
626 ")
627 (icalendar-tests--test-export
628 "%%(diary-anniversary 1989 10 3) 19:00-20:00 anniversary with time"
629 "%%(diary-anniversary 3 10 1989) 19:00-20:00 anniversary with time"
630 "%%(diary-anniversary 10 3 1989) 19:00-20:00 anniversary with time"
631 "DTSTART;VALUE=DATE-TIME:19891003T190000
632 DTEND;VALUE=DATE-TIME:19891004T200000
633 RRULE:FREQ=YEARLY;INTERVAL=1;BYMONTH=10;BYMONTHDAY=03
634 SUMMARY:anniversary with time
635 "))
636
637 (ert-deftest icalendar-export-block ()
638 "Perform export test."
639 ;; block
640 (icalendar-tests--test-export
641 "%%(diary-block 2001 6 18 2001 7 6) block no time"
642 "%%(diary-block 18 6 2001 6 7 2001) block no time"
643 "%%(diary-block 6 18 2001 7 6 2001) block no time"
644 "DTSTART;VALUE=DATE:20010618
645 DTEND;VALUE=DATE:20010707
646 SUMMARY:block no time
647 ")
648 (icalendar-tests--test-export
649 "%%(diary-block 2001 6 18 2001 7 6) 13:00-17:00 block with time"
650 "%%(diary-block 18 6 2001 6 7 2001) 13:00-17:00 block with time"
651 "%%(diary-block 6 18 2001 7 6 2001) 13:00-17:00 block with time"
652 "DTSTART;VALUE=DATE-TIME:20010618T130000
653 DTEND;VALUE=DATE-TIME:20010618T170000
654 RRULE:FREQ=DAILY;INTERVAL=1;UNTIL=20010706
655 SUMMARY:block with time
656 ")
657 (icalendar-tests--test-export
658 "%%(diary-block 2001 6 18 2001 7 6) 13:00 block no end time"
659 "%%(diary-block 18 6 2001 6 7 2001) 13:00 block no end time"
660 "%%(diary-block 6 18 2001 7 6 2001) 13:00 block no end time"
661 "DTSTART;VALUE=DATE-TIME:20010618T130000
662 DTEND;VALUE=DATE-TIME:20010618T140000
663 RRULE:FREQ=DAILY;INTERVAL=1;UNTIL=20010706
664 SUMMARY:block no end time
665 "))
666
667 ;; ======================================================================
668 ;; Import tests
669 ;; ======================================================================
670
671 (defun icalendar-tests--test-import (input expected-iso expected-european
672 expected-american)
673 "Perform import test.
674 Argument INPUT icalendar event string.
675 Argument EXPECTED-ISO expected iso style diary string.
676 Argument EXPECTED-EUROPEAN expected european style diary string.
677 Argument EXPECTED-AMERICAN expected american style diary string."
678 (let ((timezone (getenv "TZ")))
679 (unwind-protect
680 (progn
681 ;;; (message "Current time zone: %s" (current-time-zone))
682 ;; Use this form so as not to rely on system tz database.
683 ;; Eg hydra.nixos.org.
684 (setenv "TZ" "CET-1CEST,M3.5.0/2,M10.5.0/3")
685 ;;; (message "Current time zone: %s" (current-time-zone))
686 (with-temp-buffer
687 (if (string-match "^BEGIN:VCALENDAR" input)
688 (insert input)
689 (insert "BEGIN:VCALENDAR\nPRODID:-//Emacs//NONSGML icalendar.el//EN\n")
690 (insert "VERSION:2.0\nBEGIN:VEVENT\n")
691 (insert input)
692 (unless (eq (char-before) ?\n)
693 (insert "\n"))
694 (insert "END:VEVENT\nEND:VCALENDAR\n"))
695 (let ((icalendar-import-format "%s%d%l%o%t%u%c%U")
696 (icalendar-import-format-summary "%s")
697 (icalendar-import-format-location "\n Location: %s")
698 (icalendar-import-format-description "\n Desc: %s")
699 (icalendar-import-format-organizer "\n Organizer: %s")
700 (icalendar-import-format-status "\n Status: %s")
701 (icalendar-import-format-url "\n URL: %s")
702 (icalendar-import-format-class "\n Class: %s")
703 (icalendar-import-format-uid "\n UID: %s")
704 calendar-date-style)
705 (when expected-iso
706 (setq calendar-date-style 'iso)
707 (icalendar-tests--do-test-import input expected-iso))
708 (when expected-european
709 (setq calendar-date-style 'european)
710 (icalendar-tests--do-test-import input expected-european))
711 (when expected-american
712 (setq calendar-date-style 'american)
713 (icalendar-tests--do-test-import input expected-american)))))
714 (setenv "TZ" timezone))))
715
716 (defun icalendar-tests--do-test-import (input expected-output)
717 "Actually perform import test.
718 Argument INPUT input icalendar string.
719 Argument EXPECTED-OUTPUT expected diary string."
720 (let ((temp-file (make-temp-file "icalendar-test-diary")))
721 ;; Test the Catch-the-mysterious-coding-header logic below.
722 ;; Ruby-mode adds an after-save-hook which inserts the header!
723 ;; (save-excursion
724 ;; (find-file temp-file)
725 ;; (ruby-mode))
726 (icalendar-import-buffer temp-file t t)
727 (save-excursion
728 (find-file temp-file)
729 ;; Check for the mysterious "# coding: ..." header, remove it
730 ;; and give a shout
731 (goto-char (point-min))
732 (when (re-search-forward "# coding: .*?\n" nil t)
733 (message (concat "%s\n"
734 "Found mysterious \"# coding ...\" header! Removing it.\n"
735 "Current Modes: %s, %s\n"
736 "Current test: %s\n"
737 "%s")
738 (make-string 70 ?*)
739 major-mode
740 minor-mode-list
741 (ert-running-test)
742 (make-string 70 ?*))
743 (buffer-disable-undo)
744 (replace-match "")
745 (set-buffer-modified-p nil))
746
747 (let ((result (buffer-substring-no-properties (point-min) (point-max))))
748 (should (string= expected-output result)))
749 (kill-buffer (find-buffer-visiting temp-file))
750 (delete-file temp-file))))
751
752 (ert-deftest icalendar-import-non-recurring ()
753 "Perform standard import tests."
754 (icalendar-tests--test-import
755 "SUMMARY:non-recurring
756 DTSTART;VALUE=DATE-TIME:20030919T090000
757 DTEND;VALUE=DATE-TIME:20030919T113000"
758 "&2003/9/19 09:00-11:30 non-recurring\n"
759 "&19/9/2003 09:00-11:30 non-recurring\n"
760 "&9/19/2003 09:00-11:30 non-recurring\n")
761 (icalendar-tests--test-import
762 "SUMMARY:non-recurring allday
763 DTSTART;VALUE=DATE-TIME:20030919"
764 "&2003/9/19 non-recurring allday\n"
765 "&19/9/2003 non-recurring allday\n"
766 "&9/19/2003 non-recurring allday\n")
767 (icalendar-tests--test-import
768 ;; Checkdoc removes trailing blanks. Therefore: format!
769 (format "%s\n%s\n%s" "SUMMARY:long " " summary"
770 "DTSTART;VALUE=DATE:20030919")
771 "&2003/9/19 long summary\n"
772 "&19/9/2003 long summary\n"
773 "&9/19/2003 long summary\n")
774 (icalendar-tests--test-import
775 "UID:748f2da0-0d9b-11d8-97af-b4ec8686ea61
776 SUMMARY:Sommerferien
777 STATUS:TENTATIVE
778 CLASS:PRIVATE
779 X-MOZILLA-ALARM-DEFAULT-UNITS:Minuten
780 X-MOZILLA-RECUR-DEFAULT-INTERVAL:0
781 DTSTART;VALUE=DATE:20040719
782 DTEND;VALUE=DATE:20040828
783 DTSTAMP:20031103T011641Z
784 "
785 "&%%(and (diary-block 2004 7 19 2004 8 27)) Sommerferien
786 Status: TENTATIVE
787 Class: PRIVATE
788 UID: 748f2da0-0d9b-11d8-97af-b4ec8686ea61
789 "
790 "&%%(and (diary-block 19 7 2004 27 8 2004)) Sommerferien
791 Status: TENTATIVE
792 Class: PRIVATE
793 UID: 748f2da0-0d9b-11d8-97af-b4ec8686ea61
794 "
795 "&%%(and (diary-block 7 19 2004 8 27 2004)) Sommerferien
796 Status: TENTATIVE
797 Class: PRIVATE
798 UID: 748f2da0-0d9b-11d8-97af-b4ec8686ea61
799 ")
800 (icalendar-tests--test-import
801 "UID
802 :04979712-3902-11d9-93dd-8f9f4afe08da
803 SUMMARY
804 :folded summary
805 STATUS
806 :TENTATIVE
807 CLASS
808 :PRIVATE
809 X-MOZILLA-ALARM-DEFAULT-LENGTH
810 :0
811 DTSTART
812 :20041123T140000
813 DTEND
814 :20041123T143000
815 DTSTAMP
816 :20041118T013430Z
817 LAST-MODIFIED
818 :20041118T013640Z
819 "
820 "&2004/11/23 14:00-14:30 folded summary
821 Status: TENTATIVE
822 Class: PRIVATE
823 UID: 04979712-3902-11d9-93dd-8f9f4afe08da\n"
824 "&23/11/2004 14:00-14:30 folded summary
825 Status: TENTATIVE
826 Class: PRIVATE
827 UID: 04979712-3902-11d9-93dd-8f9f4afe08da\n"
828 "&11/23/2004 14:00-14:30 folded summary
829 Status: TENTATIVE
830 Class: PRIVATE
831 UID: 04979712-3902-11d9-93dd-8f9f4afe08da\n")
832
833 (icalendar-tests--test-import
834 "UID
835 :6161a312-3902-11d9-b512-f764153bb28b
836 SUMMARY
837 :another example
838 STATUS
839 :TENTATIVE
840 CLASS
841 :PRIVATE
842 X-MOZILLA-ALARM-DEFAULT-LENGTH
843 :0
844 DTSTART
845 :20041123T144500
846 DTEND
847 :20041123T154500
848 DTSTAMP
849 :20041118T013641Z
850 "
851 "&2004/11/23 14:45-15:45 another example
852 Status: TENTATIVE
853 Class: PRIVATE
854 UID: 6161a312-3902-11d9-b512-f764153bb28b\n"
855 "&23/11/2004 14:45-15:45 another example
856 Status: TENTATIVE
857 Class: PRIVATE
858 UID: 6161a312-3902-11d9-b512-f764153bb28b\n"
859 "&11/23/2004 14:45-15:45 another example
860 Status: TENTATIVE
861 Class: PRIVATE
862 UID: 6161a312-3902-11d9-b512-f764153bb28b\n"))
863
864 (ert-deftest icalendar-import-rrule ()
865 (icalendar-tests--test-import
866 "SUMMARY:rrule daily
867 DTSTART;VALUE=DATE-TIME:20030919T090000
868 DTEND;VALUE=DATE-TIME:20030919T113000
869 RRULE:FREQ=DAILY;
870 "
871 "&%%(and (diary-cyclic 1 2003 9 19)) 09:00-11:30 rrule daily\n"
872 "&%%(and (diary-cyclic 1 19 9 2003)) 09:00-11:30 rrule daily\n"
873 "&%%(and (diary-cyclic 1 9 19 2003)) 09:00-11:30 rrule daily\n")
874 ;; RRULE examples
875 (icalendar-tests--test-import
876 "SUMMARY:rrule daily
877 DTSTART;VALUE=DATE-TIME:20030919T090000
878 DTEND;VALUE=DATE-TIME:20030919T113000
879 RRULE:FREQ=DAILY;INTERVAL=2
880 "
881 "&%%(and (diary-cyclic 2 2003 9 19)) 09:00-11:30 rrule daily\n"
882 "&%%(and (diary-cyclic 2 19 9 2003)) 09:00-11:30 rrule daily\n"
883 "&%%(and (diary-cyclic 2 9 19 2003)) 09:00-11:30 rrule daily\n")
884 (icalendar-tests--test-import
885 "SUMMARY:rrule daily with exceptions
886 DTSTART;VALUE=DATE-TIME:20030919T090000
887 DTEND;VALUE=DATE-TIME:20030919T113000
888 RRULE:FREQ=DAILY;INTERVAL=2
889 EXDATE:20030921,20030925
890 "
891 "&%%(and (not (diary-date 2003 9 25)) (not (diary-date 2003 9 21)) (diary-cyclic 2 2003 9 19)) 09:00-11:30 rrule daily with exceptions\n"
892 "&%%(and (not (diary-date 25 9 2003)) (not (diary-date 21 9 2003)) (diary-cyclic 2 19 9 2003)) 09:00-11:30 rrule daily with exceptions\n"
893 "&%%(and (not (diary-date 9 25 2003)) (not (diary-date 9 21 2003)) (diary-cyclic 2 9 19 2003)) 09:00-11:30 rrule daily with exceptions\n")
894 (icalendar-tests--test-import
895 "SUMMARY:rrule weekly
896 DTSTART;VALUE=DATE-TIME:20030919T090000
897 DTEND;VALUE=DATE-TIME:20030919T113000
898 RRULE:FREQ=WEEKLY;
899 "
900 "&%%(and (diary-cyclic 7 2003 9 19)) 09:00-11:30 rrule weekly\n"
901 "&%%(and (diary-cyclic 7 19 9 2003)) 09:00-11:30 rrule weekly\n"
902 "&%%(and (diary-cyclic 7 9 19 2003)) 09:00-11:30 rrule weekly\n")
903 (icalendar-tests--test-import
904 "SUMMARY:rrule monthly no end
905 DTSTART;VALUE=DATE-TIME:20030919T090000
906 DTEND;VALUE=DATE-TIME:20030919T113000
907 RRULE:FREQ=MONTHLY;
908 "
909 "&%%(and (diary-date t t 19) (diary-block 2003 9 19 9999 1 1)) 09:00-11:30 rrule monthly no end\n"
910 "&%%(and (diary-date 19 t t) (diary-block 19 9 2003 1 1 9999)) 09:00-11:30 rrule monthly no end\n"
911 "&%%(and (diary-date t 19 t) (diary-block 9 19 2003 1 1 9999)) 09:00-11:30 rrule monthly no end\n")
912 (icalendar-tests--test-import
913 "SUMMARY:rrule monthly with end
914 DTSTART;VALUE=DATE-TIME:20030919T090000
915 DTEND;VALUE=DATE-TIME:20030919T113000
916 RRULE:FREQ=MONTHLY;UNTIL=20050819;
917 "
918 "&%%(and (diary-date t t 19) (diary-block 2003 9 19 2005 8 19)) 09:00-11:30 rrule monthly with end\n"
919 "&%%(and (diary-date 19 t t) (diary-block 19 9 2003 19 8 2005)) 09:00-11:30 rrule monthly with end\n"
920 "&%%(and (diary-date t 19 t) (diary-block 9 19 2003 8 19 2005)) 09:00-11:30 rrule monthly with end\n")
921 (icalendar-tests--test-import
922 "DTSTART;VALUE=DATE:20040815
923 DTEND;VALUE=DATE:20040816
924 SUMMARY:Maria Himmelfahrt
925 RRULE:FREQ=YEARLY;INTERVAL=1;BYMONTH=8
926 "
927 "&%%(and (diary-anniversary 2004 8 15)) Maria Himmelfahrt\n"
928 "&%%(and (diary-anniversary 15 8 2004)) Maria Himmelfahrt\n"
929 "&%%(and (diary-anniversary 8 15 2004)) Maria Himmelfahrt\n")
930 (icalendar-tests--test-import
931 "SUMMARY:rrule yearly
932 DTSTART;VALUE=DATE-TIME:20030919T090000
933 DTEND;VALUE=DATE-TIME:20030919T113000
934 RRULE:FREQ=YEARLY;INTERVAL=2
935 "
936 "&%%(and (diary-anniversary 2003 9 19)) 09:00-11:30 rrule yearly\n" ;FIXME
937 "&%%(and (diary-anniversary 19 9 2003)) 09:00-11:30 rrule yearly\n" ;FIXME
938 "&%%(and (diary-anniversary 9 19 2003)) 09:00-11:30 rrule yearly\n") ;FIXME
939 (icalendar-tests--test-import
940 "SUMMARY:rrule count daily short
941 DTSTART;VALUE=DATE-TIME:20030919T090000
942 DTEND;VALUE=DATE-TIME:20030919T113000
943 RRULE:FREQ=DAILY;COUNT=1;INTERVAL=1
944 "
945 "&%%(and (diary-cyclic 1 2003 9 19) (diary-block 2003 9 19 2003 9 19)) 09:00-11:30 rrule count daily short\n"
946 "&%%(and (diary-cyclic 1 19 9 2003) (diary-block 19 9 2003 19 9 2003)) 09:00-11:30 rrule count daily short\n"
947 "&%%(and (diary-cyclic 1 9 19 2003) (diary-block 9 19 2003 9 19 2003)) 09:00-11:30 rrule count daily short\n")
948 (icalendar-tests--test-import
949 "SUMMARY:rrule count daily long
950 DTSTART;VALUE=DATE-TIME:20030919T090000
951 DTEND;VALUE=DATE-TIME:20030919T113000
952 RRULE:FREQ=DAILY;COUNT=14;INTERVAL=1
953 "
954 "&%%(and (diary-cyclic 1 2003 9 19) (diary-block 2003 9 19 2003 10 2)) 09:00-11:30 rrule count daily long\n"
955 "&%%(and (diary-cyclic 1 19 9 2003) (diary-block 19 9 2003 2 10 2003)) 09:00-11:30 rrule count daily long\n"
956 "&%%(and (diary-cyclic 1 9 19 2003) (diary-block 9 19 2003 10 2 2003)) 09:00-11:30 rrule count daily long\n")
957 (icalendar-tests--test-import
958 "SUMMARY:rrule count bi-weekly 3 times
959 DTSTART;VALUE=DATE-TIME:20030919T090000
960 DTEND;VALUE=DATE-TIME:20030919T113000
961 RRULE:FREQ=WEEKLY;COUNT=3;INTERVAL=2
962 "
963 "&%%(and (diary-cyclic 14 2003 9 19) (diary-block 2003 9 19 2003 10 31)) 09:00-11:30 rrule count bi-weekly 3 times\n"
964 "&%%(and (diary-cyclic 14 19 9 2003) (diary-block 19 9 2003 31 10 2003)) 09:00-11:30 rrule count bi-weekly 3 times\n"
965 "&%%(and (diary-cyclic 14 9 19 2003) (diary-block 9 19 2003 10 31 2003)) 09:00-11:30 rrule count bi-weekly 3 times\n")
966 (icalendar-tests--test-import
967 "SUMMARY:rrule count monthly
968 DTSTART;VALUE=DATE-TIME:20030919T090000
969 DTEND;VALUE=DATE-TIME:20030919T113000
970 RRULE:FREQ=MONTHLY;INTERVAL=1;COUNT=5
971 "
972 "&%%(and (diary-date t t 19) (diary-block 2003 9 19 2004 1 19)) 09:00-11:30 rrule count monthly\n"
973 "&%%(and (diary-date 19 t t) (diary-block 19 9 2003 19 1 2004)) 09:00-11:30 rrule count monthly\n"
974 "&%%(and (diary-date t 19 t) (diary-block 9 19 2003 1 19 2004)) 09:00-11:30 rrule count monthly\n")
975 (icalendar-tests--test-import
976 "SUMMARY:rrule count every second month
977 DTSTART;VALUE=DATE-TIME:20030919T090000
978 DTEND;VALUE=DATE-TIME:20030919T113000
979 RRULE:FREQ=MONTHLY;INTERVAL=2;COUNT=5
980 "
981 "&%%(and (diary-date t t 19) (diary-block 2003 9 19 2004 5 19)) 09:00-11:30 rrule count every second month\n" ;FIXME
982 "&%%(and (diary-date 19 t t) (diary-block 19 9 2003 19 5 2004)) 09:00-11:30 rrule count every second month\n" ;FIXME
983 "&%%(and (diary-date t 19 t) (diary-block 9 19 2003 5 19 2004)) 09:00-11:30 rrule count every second month\n") ;FIXME
984 (icalendar-tests--test-import
985 "SUMMARY:rrule count yearly
986 DTSTART;VALUE=DATE-TIME:20030919T090000
987 DTEND;VALUE=DATE-TIME:20030919T113000
988 RRULE:FREQ=YEARLY;INTERVAL=1;COUNT=5
989 "
990 "&%%(and (diary-date t 9 19) (diary-block 2003 9 19 2007 9 19)) 09:00-11:30 rrule count yearly\n"
991 "&%%(and (diary-date 19 9 t) (diary-block 19 9 2003 19 9 2007)) 09:00-11:30 rrule count yearly\n"
992 "&%%(and (diary-date 9 19 t) (diary-block 9 19 2003 9 19 2007)) 09:00-11:30 rrule count yearly\n")
993 (icalendar-tests--test-import
994 "SUMMARY:rrule count every second year
995 DTSTART;VALUE=DATE-TIME:20030919T090000
996 DTEND;VALUE=DATE-TIME:20030919T113000
997 RRULE:FREQ=YEARLY;INTERVAL=2;COUNT=5
998 "
999 "&%%(and (diary-date t 9 19) (diary-block 2003 9 19 2011 9 19)) 09:00-11:30 rrule count every second year\n" ;FIXME!!!
1000 "&%%(and (diary-date 19 9 t) (diary-block 19 9 2003 19 9 2011)) 09:00-11:30 rrule count every second year\n" ;FIXME!!!
1001 "&%%(and (diary-date 9 19 t) (diary-block 9 19 2003 9 19 2011)) 09:00-11:30 rrule count every second year\n") ;FIXME!!!
1002 )
1003
1004 (ert-deftest icalendar-import-duration ()
1005 ;; duration
1006 (icalendar-tests--test-import
1007 "DTSTART;VALUE=DATE:20050217
1008 SUMMARY:duration
1009 DURATION:P7D
1010 "
1011 "&%%(and (diary-block 2005 2 17 2005 2 23)) duration\n"
1012 "&%%(and (diary-block 17 2 2005 23 2 2005)) duration\n"
1013 "&%%(and (diary-block 2 17 2005 2 23 2005)) duration\n")
1014 (icalendar-tests--test-import
1015 "UID:20041127T183329Z-18215-1001-4536-49109@andromeda
1016 DTSTAMP:20041127T183315Z
1017 LAST-MODIFIED:20041127T183329
1018 SUMMARY:Urlaub
1019 DTSTART;VALUE=DATE:20011221
1020 DTEND;VALUE=DATE:20011221
1021 RRULE:FREQ=DAILY;UNTIL=20011229;INTERVAL=1;WKST=SU
1022 CLASS:PUBLIC
1023 SEQUENCE:1
1024 CREATED:20041127T183329
1025 "
1026 "&%%(and (diary-cyclic 1 2001 12 21) (diary-block 2001 12 21 2001 12 29)) Urlaub
1027 Class: PUBLIC
1028 UID: 20041127T183329Z-18215-1001-4536-49109@andromeda\n"
1029 "&%%(and (diary-cyclic 1 21 12 2001) (diary-block 21 12 2001 29 12 2001)) Urlaub
1030 Class: PUBLIC
1031 UID: 20041127T183329Z-18215-1001-4536-49109@andromeda\n"
1032 "&%%(and (diary-cyclic 1 12 21 2001) (diary-block 12 21 2001 12 29 2001)) Urlaub
1033 Class: PUBLIC
1034 UID: 20041127T183329Z-18215-1001-4536-49109@andromeda\n"))
1035
1036 (ert-deftest icalendar-import-bug-6766 ()
1037 ;;bug#6766 -- multiple byday values in a weekly rrule
1038 (icalendar-tests--test-import
1039 "CLASS:PUBLIC
1040 DTEND;TZID=America/New_York:20100421T120000
1041 DTSTAMP:20100525T141214Z
1042 DTSTART;TZID=America/New_York:20100421T113000
1043 RRULE:FREQ=WEEKLY;INTERVAL=1;BYDAY=MO,WE,TH,FR
1044 SEQUENCE:1
1045 STATUS:CONFIRMED
1046 SUMMARY:Scrum
1047 TRANSP:OPAQUE
1048 UID:8814e3f9-7482-408f-996c-3bfe486a1262
1049 END:VEVENT
1050 BEGIN:VEVENT
1051 CLASS:PUBLIC
1052 DTSTAMP:20100525T141214Z
1053 DTSTART;VALUE=DATE:20100422
1054 DTEND;VALUE=DATE:20100423
1055 RRULE:FREQ=WEEKLY;INTERVAL=1;BYDAY=TU,TH
1056 SEQUENCE:1
1057 SUMMARY:Tues + Thurs thinking
1058 TRANSP:OPAQUE
1059 UID:8814e3f9-7482-408f-996c-3bfe486a1263
1060 "
1061 "&%%(and (memq (calendar-day-of-week date) '(1 3 4 5)) (diary-cyclic 1 2010 4 21)) 11:30-12:00 Scrum
1062 Status: CONFIRMED
1063 Class: PUBLIC
1064 UID: 8814e3f9-7482-408f-996c-3bfe486a1262
1065 &%%(and (memq (calendar-day-of-week date) '(2 4)) (diary-cyclic 1 2010 4 22)) Tues + Thurs thinking
1066 Class: PUBLIC
1067 UID: 8814e3f9-7482-408f-996c-3bfe486a1263
1068 "
1069 "&%%(and (memq (calendar-day-of-week date) '(1 3 4 5)) (diary-cyclic 1 21 4 2010)) 11:30-12:00 Scrum
1070 Status: CONFIRMED
1071 Class: PUBLIC
1072 UID: 8814e3f9-7482-408f-996c-3bfe486a1262
1073 &%%(and (memq (calendar-day-of-week date) '(2 4)) (diary-cyclic 1 22 4 2010)) Tues + Thurs thinking
1074 Class: PUBLIC
1075 UID: 8814e3f9-7482-408f-996c-3bfe486a1263
1076 "
1077 "&%%(and (memq (calendar-day-of-week date) '(1 3 4 5)) (diary-cyclic 1 4 21 2010)) 11:30-12:00 Scrum
1078 Status: CONFIRMED
1079 Class: PUBLIC
1080 UID: 8814e3f9-7482-408f-996c-3bfe486a1262
1081 &%%(and (memq (calendar-day-of-week date) '(2 4)) (diary-cyclic 1 4 22 2010)) Tues + Thurs thinking
1082 Class: PUBLIC
1083 UID: 8814e3f9-7482-408f-996c-3bfe486a1263
1084 "))
1085
1086 (ert-deftest icalendar-import-multiple-vcalendars ()
1087 (icalendar-tests--test-import
1088 "DTSTART;VALUE=DATE:20110723
1089 SUMMARY:event-1
1090 "
1091 "&2011/7/23 event-1\n"
1092 "&23/7/2011 event-1\n"
1093 "&7/23/2011 event-1\n")
1094
1095 (icalendar-tests--test-import
1096 "BEGIN:VCALENDAR
1097 PRODID:-//Emacs//NONSGML icalendar.el//EN
1098 VERSION:2.0\nBEGIN:VEVENT
1099 DTSTART;VALUE=DATE:20110723
1100 SUMMARY:event-1
1101 END:VEVENT
1102 END:VCALENDAR
1103 BEGIN:VCALENDAR
1104 PRODID:-//Emacs//NONSGML icalendar.el//EN
1105 VERSION:2.0
1106 BEGIN:VEVENT
1107 DTSTART;VALUE=DATE:20110724
1108 SUMMARY:event-2
1109 END:VEVENT
1110 END:VCALENDAR
1111 BEGIN:VCALENDAR
1112 PRODID:-//Emacs//NONSGML icalendar.el//EN
1113 VERSION:2.0
1114 BEGIN:VEVENT
1115 DTSTART;VALUE=DATE:20110725
1116 SUMMARY:event-3a
1117 END:VEVENT
1118 BEGIN:VEVENT
1119 DTSTART;VALUE=DATE:20110725
1120 SUMMARY:event-3b
1121 END:VEVENT
1122 END:VCALENDAR
1123 "
1124 "&2011/7/23 event-1\n&2011/7/24 event-2\n&2011/7/25 event-3a\n&2011/7/25 event-3b\n"
1125 "&23/7/2011 event-1\n&24/7/2011 event-2\n&25/7/2011 event-3a\n&25/7/2011 event-3b\n"
1126 "&7/23/2011 event-1\n&7/24/2011 event-2\n&7/25/2011 event-3a\n&7/25/2011 event-3b\n"))
1127
1128 (ert-deftest icalendar-import-with-uid ()
1129 "Perform import test with uid."
1130 (icalendar-tests--test-import
1131 "UID:1234567890uid
1132 SUMMARY:non-recurring
1133 DTSTART;VALUE=DATE-TIME:20030919T090000
1134 DTEND;VALUE=DATE-TIME:20030919T113000"
1135 "&2003/9/19 09:00-11:30 non-recurring\n UID: 1234567890uid\n"
1136 "&19/9/2003 09:00-11:30 non-recurring\n UID: 1234567890uid\n"
1137 "&9/19/2003 09:00-11:30 non-recurring\n UID: 1234567890uid\n"))
1138
1139 (ert-deftest icalendar-import-with-timezone ()
1140 ;; bug#11473
1141 (icalendar-tests--test-import
1142 "BEGIN:VCALENDAR
1143 BEGIN:VTIMEZONE
1144 TZID:fictional\, nonexistent\, arbitrary
1145 BEGIN:STANDARD
1146 DTSTART:20100101T000000
1147 TZOFFSETFROM:+0200
1148 TZOFFSETTO:-0200
1149 RRULE:FREQ=YEARLY;INTERVAL=1;BYDAY=1SU;BYMONTH=01
1150 END:STANDARD
1151 BEGIN:DAYLIGHT
1152 DTSTART:20101201T000000
1153 TZOFFSETFROM:-0200
1154 TZOFFSETTO:+0200
1155 RRULE:FREQ=YEARLY;INTERVAL=1;BYDAY=1SU;BYMONTH=11
1156 END:DAYLIGHT
1157 END:VTIMEZONE
1158 BEGIN:VEVENT
1159 SUMMARY:standardtime
1160 DTSTART;TZID=\"fictional, nonexistent, arbitrary\":20120115T120000
1161 DTEND;TZID=\"fictional, nonexistent, arbitrary\":20120115T123000
1162 END:VEVENT
1163 BEGIN:VEVENT
1164 SUMMARY:daylightsavingtime
1165 DTSTART;TZID=\"fictional, nonexistent, arbitrary\":20121215T120000
1166 DTEND;TZID=\"fictional, nonexistent, arbitrary\":20121215T123000
1167 END:VEVENT
1168 END:VCALENDAR"
1169 ;; "standardtime" begins first sunday in january and is 4 hours behind CET
1170 ;; "daylightsavingtime" begins first sunday in november and is 1 hour before CET
1171 "&2012/1/15 15:00-15:30 standardtime
1172 &2012/12/15 11:00-11:30 daylightsavingtime
1173 "
1174 nil
1175 nil)
1176 )
1177 ;; ======================================================================
1178 ;; Cycle
1179 ;; ======================================================================
1180 (defun icalendar-tests--test-cycle (input)
1181 "Perform cycle test.
1182 Argument INPUT icalendar event string."
1183 (with-temp-buffer
1184 (if (string-match "^BEGIN:VCALENDAR" input)
1185 (insert input)
1186 (insert "BEGIN:VCALENDAR\nPRODID:-//Emacs//NONSGML icalendar.el//EN\n")
1187 (insert "VERSION:2.0\nBEGIN:VEVENT\n")
1188 (insert input)
1189 (unless (eq (char-before) ?\n)
1190 (insert "\n"))
1191 (insert "END:VEVENT\nEND:VCALENDAR\n"))
1192 (let ((icalendar-import-format "%s%d%l%o%t%u%c%U")
1193 (icalendar-import-format-summary "%s")
1194 (icalendar-import-format-location "\n Location: %s")
1195 (icalendar-import-format-description "\n Desc: %s")
1196 (icalendar-import-format-organizer "\n Organizer: %s")
1197 (icalendar-import-format-status "\n Status: %s")
1198 (icalendar-import-format-url "\n URL: %s")
1199 (icalendar-import-format-class "\n Class: %s")
1200 (icalendar-import-format-class "\n UID: %s"))
1201 (dolist (calendar-date-style '(iso european american))
1202 (icalendar-tests--do-test-cycle)))))
1203
1204 (defun icalendar-tests--do-test-cycle ()
1205 "Actually perform import/export cycle test."
1206 (let ((temp-diary (make-temp-file "icalendar-test-diary"))
1207 (temp-ics (make-temp-file "icalendar-test-ics"))
1208 (org-input (buffer-substring-no-properties (point-min) (point-max))))
1209
1210 (unwind-protect
1211 (progn
1212 ;; step 1: import
1213 (icalendar-import-buffer temp-diary t t)
1214
1215 ;; step 2: export what was just imported
1216 (save-excursion
1217 (find-file temp-diary)
1218 (icalendar-export-region (point-min) (point-max) temp-ics))
1219
1220 ;; compare the output of step 2 with the input of step 1
1221 (save-excursion
1222 (find-file temp-ics)
1223 (goto-char (point-min))
1224 ;;(when (re-search-forward "\nUID:.*\n" nil t)
1225 ;;(replace-match "\n"))
1226 (let ((cycled (buffer-substring-no-properties (point-min) (point-max))))
1227 (should (string= org-input cycled)))))
1228 ;; clean up
1229 (kill-buffer (find-buffer-visiting temp-diary))
1230 (with-current-buffer (find-buffer-visiting temp-ics)
1231 (set-buffer-modified-p nil)
1232 (kill-buffer (current-buffer)))
1233 (delete-file temp-diary)
1234 (delete-file temp-ics))))
1235
1236 (ert-deftest icalendar-cycle ()
1237 "Perform cycling tests.
1238 Take care to avoid auto-generated UIDs here."
1239 (icalendar-tests--test-cycle
1240 "UID:dummyuid
1241 DTSTART;VALUE=DATE-TIME:20030919T090000
1242 DTEND;VALUE=DATE-TIME:20030919T113000
1243 SUMMARY:Cycletest
1244 ")
1245 (icalendar-tests--test-cycle
1246 "UID:blah
1247 DTSTART;VALUE=DATE-TIME:20030919T090000
1248 DTEND;VALUE=DATE-TIME:20030919T113000
1249 SUMMARY:Cycletest
1250 DESCRIPTION:beschreibung!
1251 LOCATION:nowhere
1252 ORGANIZER:ulf
1253 ")
1254 (icalendar-tests--test-cycle
1255 "UID:4711
1256 DTSTART;VALUE=DATE:19190909
1257 DTEND;VALUE=DATE:19190910
1258 RRULE:FREQ=YEARLY;INTERVAL=1;BYMONTH=09;BYMONTHDAY=09
1259 SUMMARY:and diary-anniversary
1260 "))
1261
1262 ;; ======================================================================
1263 ;; Real world
1264 ;; ======================================================================
1265 (ert-deftest icalendar-real-world ()
1266 "Perform real-world tests, as gathered from problem reports."
1267 ;; 2003-05-29
1268 (icalendar-tests--test-import
1269 "BEGIN:VCALENDAR
1270 METHOD:REQUEST
1271 PRODID:Microsoft CDO for Microsoft Exchange
1272 VERSION:2.0
1273 BEGIN:VTIMEZONE
1274 TZID:Kolkata\, Chennai\, Mumbai\, New Delhi
1275 X-MICROSOFT-CDO-TZID:23
1276 BEGIN:STANDARD
1277 DTSTART:16010101T000000
1278 TZOFFSETFROM:+0530
1279 TZOFFSETTO:+0530
1280 END:STANDARD
1281 BEGIN:DAYLIGHT
1282 DTSTART:16010101T000000
1283 TZOFFSETFROM:+0530
1284 TZOFFSETTO:+0530
1285 END:DAYLIGHT
1286 END:VTIMEZONE
1287 BEGIN:VEVENT
1288 DTSTAMP:20030509T043439Z
1289 DTSTART;TZID=\"Kolkata, Chennai, Mumbai, New Delhi\":20030509T103000
1290 SUMMARY:On-Site Interview
1291 UID:040000008200E00074C5B7101A82E0080000000080B6DE661216C301000000000000000
1292 010000000DB823520692542408ED02D7023F9DFF9
1293 ATTENDEE;ROLE=REQ-PARTICIPANT;PARTSTAT=NEEDS-ACTION;RSVP=TRUE;CN=\"Xxxxx
1294 xxx Xxxxxxxxxxxx\":MAILTO:xxxxxxxx@xxxxxxx.com
1295 ATTENDEE;ROLE=REQ-PARTICIPANT;PARTSTAT=NEEDS-ACTION;RSVP=TRUE;CN=\"Yyyyyyy Y
1296 yyyy\":MAILTO:yyyyyyy@yyyyyyy.com
1297 ATTENDEE;ROLE=REQ-PARTICIPANT;PARTSTAT=NEEDS-ACTION;RSVP=TRUE;CN=\"Zzzz Zzzz
1298 zz\":MAILTO:zzzzzz@zzzzzzz.com
1299 ORGANIZER;CN=\"Aaaaaa Aaaaa\":MAILTO:aaaaaaa@aaaaaaa.com
1300 LOCATION:Cccc
1301 DTEND;TZID=\"Kolkata, Chennai, Mumbai, New Delhi\":20030509T153000
1302 DESCRIPTION:10:30am - Blah
1303 SEQUENCE:0
1304 PRIORITY:5
1305 CLASS:
1306 CREATED:20030509T043439Z
1307 LAST-MODIFIED:20030509T043459Z
1308 STATUS:CONFIRMED
1309 TRANSP:OPAQUE
1310 X-MICROSOFT-CDO-BUSYSTATUS:BUSY
1311 X-MICROSOFT-CDO-INSTTYPE:0
1312 X-MICROSOFT-CDO-INTENDEDSTATUS:BUSY
1313 X-MICROSOFT-CDO-ALLDAYEVENT:FALSE
1314 X-MICROSOFT-CDO-IMPORTANCE:1
1315 X-MICROSOFT-CDO-OWNERAPPTID:126441427
1316 BEGIN:VALARM
1317 ACTION:DISPLAY
1318 DESCRIPTION:REMINDER
1319 TRIGGER;RELATED=START:-PT00H15M00S
1320 END:VALARM
1321 END:VEVENT
1322 END:VCALENDAR"
1323 nil
1324 "&9/5/2003 10:30-15:30 On-Site Interview
1325 Desc: 10:30am - Blah
1326 Location: Cccc
1327 Organizer: MAILTO:aaaaaaa@aaaaaaa.com
1328 Status: CONFIRMED
1329 UID: 040000008200E00074C5B7101A82E0080000000080B6DE661216C301000000000000000010000000DB823520692542408ED02D7023F9DFF9
1330 "
1331 "&5/9/2003 10:30-15:30 On-Site Interview
1332 Desc: 10:30am - Blah
1333 Location: Cccc
1334 Organizer: MAILTO:aaaaaaa@aaaaaaa.com
1335 Status: CONFIRMED
1336 UID: 040000008200E00074C5B7101A82E0080000000080B6DE661216C301000000000000000010000000DB823520692542408ED02D7023F9DFF9
1337 ")
1338
1339 ;; 2003-06-18 a
1340 (icalendar-tests--test-import
1341 "DTSTAMP:20030618T195512Z
1342 DTSTART;TZID=\"Mountain Time (US & Canada)\":20030623T110000
1343 SUMMARY:Dress Rehearsal for XXXX-XXXX
1344 UID:040000008200E00074C5B7101A82E00800000000608AA7DA9835C301000000000000000
1345 0100000007C3A6D65EE726E40B7F3D69A23BD567E
1346 ATTENDEE;ROLE=REQ-PARTICIPANT;PARTSTAT=NEEDS-ACTION;RSVP=TRUE;CN=\"AAAAA,AAA
1347 AA (A-AAAAAAA,ex1)\":MAILTO:aaaaa_aaaaa@aaaaa.com
1348 ORGANIZER;CN=\"ABCD,TECHTRAINING
1349 (A-Americas,exgen1)\":MAILTO:xxx@xxxxx.com
1350 LOCATION:555 or TN 555-5555 ID 5555 & NochWas (see below)
1351 DTEND;TZID=\"Mountain Time (US & Canada)\":20030623T120000
1352 DESCRIPTION:753 Zeichen hier radiert
1353 SEQUENCE:0
1354 PRIORITY:5
1355 CLASS:
1356 CREATED:20030618T195518Z
1357 LAST-MODIFIED:20030618T195527Z
1358 STATUS:CONFIRMED
1359 TRANSP:OPAQUE
1360 X-MICROSOFT-CDO-BUSYSTATUS:BUSY
1361 X-MICROSOFT-CDO-INSTTYPE:0
1362 X-MICROSOFT-CDO-INTENDEDSTATUS:BUSY
1363 X-MICROSOFT-CDO-ALLDAYEVENT:FALSE
1364 X-MICROSOFT-CDO-IMPORTANCE:1
1365 X-MICROSOFT-CDO-OWNERAPPTID:1022519251
1366 BEGIN:VALARM
1367 ACTION:DISPLAY
1368 DESCRIPTION:REMINDER
1369 TRIGGER;RELATED=START:-PT00H15M00S
1370 END:VALARM"
1371 nil
1372 "&23/6/2003 11:00-12:00 Dress Rehearsal for XXXX-XXXX
1373 Desc: 753 Zeichen hier radiert
1374 Location: 555 or TN 555-5555 ID 5555 & NochWas (see below)
1375 Organizer: MAILTO:xxx@xxxxx.com
1376 Status: CONFIRMED
1377 UID: 040000008200E00074C5B7101A82E00800000000608AA7DA9835C3010000000000000000100000007C3A6D65EE726E40B7F3D69A23BD567E
1378 "
1379 "&6/23/2003 11:00-12:00 Dress Rehearsal for XXXX-XXXX
1380 Desc: 753 Zeichen hier radiert
1381 Location: 555 or TN 555-5555 ID 5555 & NochWas (see below)
1382 Organizer: MAILTO:xxx@xxxxx.com
1383 Status: CONFIRMED
1384 UID: 040000008200E00074C5B7101A82E00800000000608AA7DA9835C3010000000000000000100000007C3A6D65EE726E40B7F3D69A23BD567E
1385 ")
1386 ;; 2003-06-18 b -- uses timezone
1387 (icalendar-tests--test-import
1388 "BEGIN:VCALENDAR
1389 METHOD:REQUEST
1390 PRODID:Microsoft CDO for Microsoft Exchange
1391 VERSION:2.0
1392 BEGIN:VTIMEZONE
1393 TZID:Mountain Time (US & Canada)
1394 X-MICROSOFT-CDO-TZID:12
1395 BEGIN:STANDARD
1396 DTSTART:16010101T020000
1397 TZOFFSETFROM:-0600
1398 TZOFFSETTO:-0700
1399 RRULE:FREQ=YEARLY;WKST=MO;INTERVAL=1;BYMONTH=10;BYDAY=-1SU
1400 END:STANDARD
1401 BEGIN:DAYLIGHT
1402 DTSTART:16010101T020000
1403 TZOFFSETFROM:-0700
1404 TZOFFSETTO:-0600
1405 RRULE:FREQ=YEARLY;WKST=MO;INTERVAL=1;BYMONTH=4;BYDAY=1SU
1406 END:DAYLIGHT
1407 END:VTIMEZONE
1408 BEGIN:VEVENT
1409 DTSTAMP:20030618T230323Z
1410 DTSTART;TZID=\"Mountain Time (US & Canada)\":20030623T090000
1411 SUMMARY:Updated: Dress Rehearsal for ABC01-15
1412 UID:040000008200E00074C5B7101A82E00800000000608AA7DA9835C301000000000000000
1413 0100000007C3A6D65EE726E40B7F3D69A23BD567E
1414 ATTENDEE;ROLE=REQ-PARTICIPANT;PARTSTAT=NEEDS-ACTION;X-REPLYTIME=20030618T20
1415 0700Z;RSVP=TRUE;CN=\"AAAAA,AAAAAA
1416 \(A-AAAAAAA,ex1)\":MAILTO:aaaaaa_aaaaa@aaaaa
1417 .com
1418 ORGANIZER;CN=\"ABCD,TECHTRAINING
1419 \(A-Americas,exgen1)\":MAILTO:bbb@bbbbb.com
1420 LOCATION:123 or TN 123-1234 ID abcd & SonstWo (see below)
1421 DTEND;TZID=\"Mountain Time (US & Canada)\":20030623T100000
1422 DESCRIPTION:Viele Zeichen standen hier früher
1423 SEQUENCE:0
1424 PRIORITY:5
1425 CLASS:
1426 CREATED:20030618T230326Z
1427 LAST-MODIFIED:20030618T230335Z
1428 STATUS:CONFIRMED
1429 TRANSP:OPAQUE
1430 X-MICROSOFT-CDO-BUSYSTATUS:BUSY
1431 X-MICROSOFT-CDO-INSTTYPE:0
1432 X-MICROSOFT-CDO-INTENDEDSTATUS:BUSY
1433 X-MICROSOFT-CDO-ALLDAYEVENT:FALSE
1434 X-MICROSOFT-CDO-IMPORTANCE:1
1435 X-MICROSOFT-CDO-OWNERAPPTID:1022519251
1436 BEGIN:VALARM
1437 ACTION:DISPLAY
1438 DESCRIPTION:REMINDER
1439 TRIGGER;RELATED=START:-PT00H15M00S
1440 END:VALARM
1441 END:VEVENT
1442 END:VCALENDAR"
1443 nil
1444 "&23/6/2003 17:00-18:00 Updated: Dress Rehearsal for ABC01-15
1445 Desc: Viele Zeichen standen hier früher
1446 Location: 123 or TN 123-1234 ID abcd & SonstWo (see below)
1447 Organizer: MAILTO:bbb@bbbbb.com
1448 Status: CONFIRMED
1449 UID: 040000008200E00074C5B7101A82E00800000000608AA7DA9835C3010000000000000000100000007C3A6D65EE726E40B7F3D69A23BD567E
1450 "
1451 "&6/23/2003 17:00-18:00 Updated: Dress Rehearsal for ABC01-15
1452 Desc: Viele Zeichen standen hier früher
1453 Location: 123 or TN 123-1234 ID abcd & SonstWo (see below)
1454 Organizer: MAILTO:bbb@bbbbb.com
1455 Status: CONFIRMED
1456 UID: 040000008200E00074C5B7101A82E00800000000608AA7DA9835C3010000000000000000100000007C3A6D65EE726E40B7F3D69A23BD567E
1457 ")
1458 ;; export 2004-10-28 block entries
1459 (icalendar-tests--test-export
1460 nil
1461 nil
1462 "-*- mode: text; fill-column: 256;-*-
1463
1464 >>> block entries:
1465
1466 %%(diary-block 11 8 2004 11 10 2004) Nov 8-10 aa
1467 "
1468 "DTSTART;VALUE=DATE:20041108
1469 DTEND;VALUE=DATE:20041111
1470 SUMMARY:Nov 8-10 aa")
1471
1472 (icalendar-tests--test-export
1473 nil
1474 nil
1475 "%%(diary-block 12 13 2004 12 17 2004) Dec 13-17 bb"
1476 "DTSTART;VALUE=DATE:20041213
1477 DTEND;VALUE=DATE:20041218
1478 SUMMARY:Dec 13-17 bb")
1479
1480 (icalendar-tests--test-export
1481 nil
1482 nil
1483 "%%(diary-block 2 3 2005 2 4 2005) Feb 3-4 cc"
1484 "DTSTART;VALUE=DATE:20050203
1485 DTEND;VALUE=DATE:20050205
1486 SUMMARY:Feb 3-4 cc")
1487
1488 (icalendar-tests--test-export
1489 nil
1490 nil
1491 "%%(diary-block 4 24 2005 4 29 2005) April 24-29 dd"
1492 "DTSTART;VALUE=DATE:20050424
1493 DTEND;VALUE=DATE:20050430
1494 SUMMARY:April 24-29 dd
1495 ")
1496 (icalendar-tests--test-export
1497 nil
1498 nil
1499 "%%(diary-block 5 30 2005 6 1 2005) may 30 - June 1: ee"
1500 "DTSTART;VALUE=DATE:20050530
1501 DTEND;VALUE=DATE:20050602
1502 SUMMARY:may 30 - June 1: ee")
1503
1504 (icalendar-tests--test-export
1505 nil
1506 nil
1507 "%%(diary-block 6 6 2005 6 8 2005) ff"
1508 "DTSTART;VALUE=DATE:20050606
1509 DTEND;VALUE=DATE:20050609
1510 SUMMARY:ff")
1511
1512 ;; export 2004-10-28 anniversary entries
1513 (icalendar-tests--test-export
1514 nil
1515 nil
1516 "
1517 >>> anniversaries:
1518
1519 %%(diary-anniversary 3 28 1991) aa birthday (%d years old)"
1520 "DTSTART;VALUE=DATE:19910328
1521 DTEND;VALUE=DATE:19910329
1522 RRULE:FREQ=YEARLY;INTERVAL=1;BYMONTH=03;BYMONTHDAY=28
1523 SUMMARY:aa birthday (%d years old)
1524 ")
1525
1526 (icalendar-tests--test-export
1527 nil
1528 nil
1529 "%%(diary-anniversary 5 17 1957) bb birthday (%d years old)"
1530 "DTSTART;VALUE=DATE:19570517
1531 DTEND;VALUE=DATE:19570518
1532 RRULE:FREQ=YEARLY;INTERVAL=1;BYMONTH=05;BYMONTHDAY=17
1533 SUMMARY:bb birthday (%d years old)")
1534
1535 (icalendar-tests--test-export
1536 nil
1537 nil
1538 "%%(diary-anniversary 6 8 1997) cc birthday (%d years old)"
1539 "DTSTART;VALUE=DATE:19970608
1540 DTEND;VALUE=DATE:19970609
1541 RRULE:FREQ=YEARLY;INTERVAL=1;BYMONTH=06;BYMONTHDAY=08
1542 SUMMARY:cc birthday (%d years old)")
1543
1544 (icalendar-tests--test-export
1545 nil
1546 nil
1547 "%%(diary-anniversary 7 22 1983) dd (%d years ago...!)"
1548 "DTSTART;VALUE=DATE:19830722
1549 DTEND;VALUE=DATE:19830723
1550 RRULE:FREQ=YEARLY;INTERVAL=1;BYMONTH=07;BYMONTHDAY=22
1551 SUMMARY:dd (%d years ago...!)")
1552
1553 (icalendar-tests--test-export
1554 nil
1555 nil
1556 "%%(diary-anniversary 8 1 1988) ee birthday (%d years old)"
1557 "DTSTART;VALUE=DATE:19880801
1558 DTEND;VALUE=DATE:19880802
1559 RRULE:FREQ=YEARLY;INTERVAL=1;BYMONTH=08;BYMONTHDAY=01
1560 SUMMARY:ee birthday (%d years old)")
1561
1562 (icalendar-tests--test-export
1563 nil
1564 nil
1565 "%%(diary-anniversary 9 21 1957) ff birthday (%d years old)"
1566 "DTSTART;VALUE=DATE:19570921
1567 DTEND;VALUE=DATE:19570922
1568 RRULE:FREQ=YEARLY;INTERVAL=1;BYMONTH=09;BYMONTHDAY=21
1569 SUMMARY:ff birthday (%d years old)")
1570
1571
1572 ;; FIXME!
1573
1574 ;; export 2004-10-28 monthly, weekly entries
1575
1576 ;; (icalendar-tests--test-export
1577 ;; nil
1578 ;; "
1579 ;; >>> ------------ monthly:
1580
1581 ;; */27/* 10:00 blah blah"
1582 ;; "xxx")
1583
1584 (icalendar-tests--test-export
1585 nil
1586 nil
1587 ">>> ------------ my week:
1588
1589 Monday 13:00 MAC"
1590 "DTSTART;VALUE=DATE-TIME:20000103T130000
1591 DTEND;VALUE=DATE-TIME:20000103T140000
1592 RRULE:FREQ=WEEKLY;INTERVAL=1;BYDAY=MO
1593 SUMMARY:MAC")
1594
1595 (icalendar-tests--test-export
1596 nil
1597 nil
1598 "Monday 15:00 a1"
1599 "DTSTART;VALUE=DATE-TIME:20000103T150000
1600 DTEND;VALUE=DATE-TIME:20000103T160000
1601 RRULE:FREQ=WEEKLY;INTERVAL=1;BYDAY=MO
1602 SUMMARY:a1")
1603
1604
1605 (icalendar-tests--test-export
1606 nil
1607 nil
1608 "Monday 16:00-17:00 a2"
1609 "DTSTART;VALUE=DATE-TIME:20000103T160000
1610 DTEND;VALUE=DATE-TIME:20000103T170000
1611 RRULE:FREQ=WEEKLY;INTERVAL=1;BYDAY=MO
1612 SUMMARY:a2")
1613
1614 (icalendar-tests--test-export
1615 nil
1616 nil
1617 "Tuesday 11:30-13:00 a3"
1618 "DTSTART;VALUE=DATE-TIME:20000104T113000
1619 DTEND;VALUE=DATE-TIME:20000104T130000
1620 RRULE:FREQ=WEEKLY;INTERVAL=1;BYDAY=TU
1621 SUMMARY:a3")
1622
1623 (icalendar-tests--test-export
1624 nil
1625 nil
1626 "Tuesday 15:00 a4"
1627 "DTSTART;VALUE=DATE-TIME:20000104T150000
1628 DTEND;VALUE=DATE-TIME:20000104T160000
1629 RRULE:FREQ=WEEKLY;INTERVAL=1;BYDAY=TU
1630 SUMMARY:a4")
1631
1632 (icalendar-tests--test-export
1633 nil
1634 nil
1635 "Wednesday 13:00 a5"
1636 "DTSTART;VALUE=DATE-TIME:20000105T130000
1637 DTEND;VALUE=DATE-TIME:20000105T140000
1638 RRULE:FREQ=WEEKLY;INTERVAL=1;BYDAY=WE
1639 SUMMARY:a5")
1640
1641 (icalendar-tests--test-export
1642 nil
1643 nil
1644 "Wednesday 11:30-13:30 a6"
1645 "DTSTART;VALUE=DATE-TIME:20000105T113000
1646 DTEND;VALUE=DATE-TIME:20000105T133000
1647 RRULE:FREQ=WEEKLY;INTERVAL=1;BYDAY=WE
1648 SUMMARY:a6")
1649
1650 (icalendar-tests--test-export
1651 nil
1652 nil
1653 "Wednesday 15:00 s1"
1654 "DTSTART;VALUE=DATE-TIME:20000105T150000
1655 DTEND;VALUE=DATE-TIME:20000105T160000
1656 RRULE:FREQ=WEEKLY;INTERVAL=1;BYDAY=WE
1657 SUMMARY:s1")
1658
1659
1660 ;; export 2004-10-28 regular entries
1661 (icalendar-tests--test-export
1662 nil
1663 nil
1664 "
1665 >>> regular diary entries:
1666
1667 Oct 12 2004, 14:00 Tue: [2004-10-12] q1"
1668 "DTSTART;VALUE=DATE-TIME:20041012T140000
1669 DTEND;VALUE=DATE-TIME:20041012T150000
1670 SUMMARY:Tue: [2004-10-12] q1")
1671
1672 ;; 2004-11-19
1673 (icalendar-tests--test-import
1674 "BEGIN:VCALENDAR
1675 VERSION
1676 :2.0
1677 PRODID
1678 :-//Mozilla.org/NONSGML Mozilla Calendar V1.0//EN
1679 BEGIN:VEVENT
1680 SUMMARY
1681 :Jjjjj & Wwwww
1682 STATUS
1683 :TENTATIVE
1684 CLASS
1685 :PRIVATE
1686 X-MOZILLA-ALARM-DEFAULT-LENGTH
1687 :0
1688 DTSTART
1689 :20041123T140000
1690 DTEND
1691 :20041123T143000
1692 DTSTAMP
1693 :20041118T013430Z
1694 LAST-MODIFIED
1695 :20041118T013640Z
1696 END:VEVENT
1697 BEGIN:VEVENT
1698 SUMMARY
1699 :BB Aaaaaaaa Bbbbb
1700 STATUS
1701 :TENTATIVE
1702 CLASS
1703 :PRIVATE
1704 X-MOZILLA-ALARM-DEFAULT-LENGTH
1705 :0
1706 DTSTART
1707 :20041123T144500
1708 DTEND
1709 :20041123T154500
1710 DTSTAMP
1711 :20041118T013641Z
1712 END:VEVENT
1713 BEGIN:VEVENT
1714 SUMMARY
1715 :Hhhhhhhh
1716 STATUS
1717 :TENTATIVE
1718 CLASS
1719 :PRIVATE
1720 X-MOZILLA-ALARM-DEFAULT-LENGTH
1721 :0
1722 DTSTART
1723 :20041123T110000
1724 DTEND
1725 :20041123T120000
1726 DTSTAMP
1727 :20041118T013831Z
1728 END:VEVENT
1729 BEGIN:VEVENT
1730 SUMMARY
1731 :MMM Aaaaaaaaa
1732 STATUS
1733 :TENTATIVE
1734 CLASS
1735 :PRIVATE
1736 X-MOZILLA-ALARM-DEFAULT-LENGTH
1737 :0
1738 X-MOZILLA-RECUR-DEFAULT-INTERVAL
1739 :2
1740 RRULE
1741 :FREQ=WEEKLY;INTERVAL=2;BYDAY=FR
1742 DTSTART
1743 :20041112T140000
1744 DTEND
1745 :20041112T183000
1746 DTSTAMP
1747 :20041118T014117Z
1748 END:VEVENT
1749 BEGIN:VEVENT
1750 SUMMARY
1751 :Rrrr/Cccccc ii Aaaaaaaa
1752 DESCRIPTION
1753 :Vvvvv Rrrr aaa Cccccc
1754 STATUS
1755 :TENTATIVE
1756 CLASS
1757 :PRIVATE
1758 X-MOZILLA-ALARM-DEFAULT-LENGTH
1759 :0
1760 DTSTART
1761 ;VALUE=DATE
1762 :20041119
1763 DTEND
1764 ;VALUE=DATE
1765 :20041120
1766 DTSTAMP
1767 :20041118T013107Z
1768 LAST-MODIFIED
1769 :20041118T014203Z
1770 END:VEVENT
1771 BEGIN:VEVENT
1772 SUMMARY
1773 :Wwww aa hhhh
1774 STATUS
1775 :TENTATIVE
1776 CLASS
1777 :PRIVATE
1778 X-MOZILLA-ALARM-DEFAULT-LENGTH
1779 :0
1780 RRULE
1781 :FREQ=WEEKLY;INTERVAL=1;BYDAY=MO
1782 DTSTART
1783 ;VALUE=DATE
1784 :20041101
1785 DTEND
1786 ;VALUE=DATE
1787 :20041102
1788 DTSTAMP
1789 :20041118T014045Z
1790 LAST-MODIFIED
1791 :20041118T023846Z
1792 END:VEVENT
1793 END:VCALENDAR
1794 "
1795 nil
1796 "&23/11/2004 14:00-14:30 Jjjjj & Wwwww
1797 Status: TENTATIVE
1798 Class: PRIVATE
1799 &23/11/2004 14:45-15:45 BB Aaaaaaaa Bbbbb
1800 Status: TENTATIVE
1801 Class: PRIVATE
1802 &23/11/2004 11:00-12:00 Hhhhhhhh
1803 Status: TENTATIVE
1804 Class: PRIVATE
1805 &%%(and (diary-cyclic 14 12 11 2004)) 14:00-18:30 MMM Aaaaaaaaa
1806 Status: TENTATIVE
1807 Class: PRIVATE
1808 &%%(and (diary-block 19 11 2004 19 11 2004)) Rrrr/Cccccc ii Aaaaaaaa
1809 Desc: Vvvvv Rrrr aaa Cccccc
1810 Status: TENTATIVE
1811 Class: PRIVATE
1812 &%%(and (diary-cyclic 7 1 11 2004)) Wwww aa hhhh
1813 Status: TENTATIVE
1814 Class: PRIVATE
1815 "
1816 "&11/23/2004 14:00-14:30 Jjjjj & Wwwww
1817 Status: TENTATIVE
1818 Class: PRIVATE
1819 &11/23/2004 14:45-15:45 BB Aaaaaaaa Bbbbb
1820 Status: TENTATIVE
1821 Class: PRIVATE
1822 &11/23/2004 11:00-12:00 Hhhhhhhh
1823 Status: TENTATIVE
1824 Class: PRIVATE
1825 &%%(and (diary-cyclic 14 11 12 2004)) 14:00-18:30 MMM Aaaaaaaaa
1826 Status: TENTATIVE
1827 Class: PRIVATE
1828 &%%(and (diary-block 11 19 2004 11 19 2004)) Rrrr/Cccccc ii Aaaaaaaa
1829 Desc: Vvvvv Rrrr aaa Cccccc
1830 Status: TENTATIVE
1831 Class: PRIVATE
1832 &%%(and (diary-cyclic 7 11 1 2004)) Wwww aa hhhh
1833 Status: TENTATIVE
1834 Class: PRIVATE
1835 ")
1836
1837 ;; 2004-09-09 pg
1838 (icalendar-tests--test-export
1839 "%%(diary-block 1 1 2004 4 1 2004) Urlaub"
1840 nil
1841 nil
1842 "DTSTART;VALUE=DATE:20040101
1843 DTEND;VALUE=DATE:20040105
1844 SUMMARY:Urlaub")
1845
1846 ;; 2004-10-25 pg
1847 (icalendar-tests--test-export
1848 nil
1849 "5 11 2004 Bla Fasel"
1850 nil
1851 "DTSTART;VALUE=DATE:20041105
1852 DTEND;VALUE=DATE:20041106
1853 SUMMARY:Bla Fasel")
1854
1855 ;; 2004-10-30 pg
1856 (icalendar-tests--test-export
1857 nil
1858 "2 Nov 2004 15:00-16:30 Zahnarzt"
1859 nil
1860 "DTSTART;VALUE=DATE-TIME:20041102T150000
1861 DTEND;VALUE=DATE-TIME:20041102T163000
1862 SUMMARY:Zahnarzt")
1863
1864 ;; 2005-02-07 lt
1865 (icalendar-tests--test-import
1866 "UID
1867 :b60d398e-1dd1-11b2-a159-cf8cb05139f4
1868 SUMMARY
1869 :Waitangi Day
1870 DESCRIPTION
1871 :abcdef
1872 CATEGORIES
1873 :Public Holiday
1874 STATUS
1875 :CONFIRMED
1876 CLASS
1877 :PRIVATE
1878 DTSTART
1879 ;VALUE=DATE
1880 :20050206
1881 DTEND
1882 ;VALUE=DATE
1883 :20050207
1884 DTSTAMP
1885 :20050128T011209Z"
1886 nil
1887 "&%%(and (diary-block 6 2 2005 6 2 2005)) Waitangi Day
1888 Desc: abcdef
1889 Status: CONFIRMED
1890 Class: PRIVATE
1891 UID: b60d398e-1dd1-11b2-a159-cf8cb05139f4
1892 "
1893 "&%%(and (diary-block 2 6 2005 2 6 2005)) Waitangi Day
1894 Desc: abcdef
1895 Status: CONFIRMED
1896 Class: PRIVATE
1897 UID: b60d398e-1dd1-11b2-a159-cf8cb05139f4
1898 ")
1899
1900 ;; 2005-03-01 lt
1901 (icalendar-tests--test-import
1902 "DTSTART;VALUE=DATE:20050217
1903 SUMMARY:Hhhhhh Aaaaa ii Aaaaaaaa
1904 UID:6AFA7558-6994-11D9-8A3A-000A95A0E830-RID
1905 DTSTAMP:20050118T210335Z
1906 DURATION:P7D"
1907 nil
1908 "&%%(and (diary-block 17 2 2005 23 2 2005)) Hhhhhh Aaaaa ii Aaaaaaaa
1909 UID: 6AFA7558-6994-11D9-8A3A-000A95A0E830-RID\n"
1910 "&%%(and (diary-block 2 17 2005 2 23 2005)) Hhhhhh Aaaaa ii Aaaaaaaa
1911 UID: 6AFA7558-6994-11D9-8A3A-000A95A0E830-RID\n")
1912
1913 ;; 2005-03-23 lt
1914 (icalendar-tests--test-export
1915 nil
1916 "&%%(diary-cyclic 7 8 2 2005) 16:00-16:45 [WORK] Pppp"
1917 nil
1918 "DTSTART;VALUE=DATE-TIME:20050208T160000
1919 DTEND;VALUE=DATE-TIME:20050208T164500
1920 RRULE:FREQ=DAILY;INTERVAL=7
1921 SUMMARY:[WORK] Pppp
1922 ")
1923
1924 ;; 2005-05-27 eu
1925 (icalendar-tests--test-export
1926 nil
1927 nil
1928 ;; FIXME: colon not allowed!
1929 ;;"Nov 1: NNN Wwwwwwww Wwwww - Aaaaaa Pppppppp rrrrrr ddd oo Nnnnnnnn 30"
1930 "Nov 1 NNN Wwwwwwww Wwwww - Aaaaaa Pppppppp rrrrrr ddd oo Nnnnnnnn 30"
1931 "DTSTART;VALUE=DATE:19001101
1932 DTEND;VALUE=DATE:19001102
1933 RRULE:FREQ=YEARLY;INTERVAL=1;BYMONTH=11;BYMONTHDAY=1
1934 SUMMARY:NNN Wwwwwwww Wwwww - Aaaaaa Pppppppp rrrrrr ddd oo Nnnnnnnn 30
1935 ")
1936
1937 ;; bug#11473
1938 (icalendar-tests--test-import
1939 "BEGIN:VCALENDAR
1940 METHOD:REQUEST
1941 PRODID:Microsoft Exchange Server 2007
1942 VERSION:2.0
1943 BEGIN:VTIMEZONE
1944 TZID:(UTC+01:00) Amsterdam\, Berlin\, Bern\, Rome\, Stockholm\, Vienna
1945 BEGIN:STANDARD
1946 DTSTART:16010101T030000
1947 TZOFFSETFROM:+0200
1948 TZOFFSETTO:+0100
1949 RRULE:FREQ=YEARLY;INTERVAL=1;BYDAY=-1SU;BYMONTH=10
1950 END:STANDARD
1951 BEGIN:DAYLIGHT
1952 DTSTART:16010101T020000
1953 TZOFFSETFROM:+0100
1954 TZOFFSETTO:+0200
1955 RRULE:FREQ=YEARLY;INTERVAL=1;BYDAY=-1SU;BYMONTH=3
1956 END:DAYLIGHT
1957 END:VTIMEZONE
1958 BEGIN:VEVENT
1959 ORGANIZER;CN=\"A. Luser\":MAILTO:a.luser@foo.com
1960 ATTENDEE;ROLE=REQ-PARTICIPANT;PARTSTAT=NEEDS-ACTION;RSVP=TRUE;CN=\"Luser, Oth
1961 er\":MAILTO:other.luser@foo.com
1962 DESCRIPTION;LANGUAGE=en-US:\nWhassup?\n\n
1963 SUMMARY;LANGUAGE=en-US:Query
1964 DTSTART;TZID=\"(UTC+01:00) Amsterdam, Berlin, Bern, Rome, Stockholm, Vienna\"
1965 :20120515T150000
1966 DTEND;TZID=\"(UTC+01:00) Amsterdam, Berlin, Bern, Rome, Stockholm, Vienna\":2
1967 0120515T153000
1968 UID:040000008200E00074C5B7101A82E0080000000020FFAED0CFEFCC01000000000000000
1969 010000000575268034ECDB649A15349B1BF240F15
1970 RECURRENCE-ID;TZID=\"(UTC+01:00) Amsterdam, Berlin, Bern, Rome, Stockholm, V
1971 ienna\":20120515T170000
1972 CLASS:PUBLIC
1973 PRIORITY:5
1974 DTSTAMP:20120514T153645Z
1975 TRANSP:OPAQUE
1976 STATUS:CONFIRMED
1977 SEQUENCE:15
1978 LOCATION;LANGUAGE=en-US:phone
1979 X-MICROSOFT-CDO-APPT-SEQUENCE:15
1980 X-MICROSOFT-CDO-OWNERAPPTID:1907632092
1981 X-MICROSOFT-CDO-BUSYSTATUS:TENTATIVE
1982 X-MICROSOFT-CDO-INTENDEDSTATUS:BUSY
1983 X-MICROSOFT-CDO-ALLDAYEVENT:FALSE
1984 X-MICROSOFT-CDO-IMPORTANCE:1
1985 X-MICROSOFT-CDO-INSTTYPE:3
1986 BEGIN:VALARM
1987 ACTION:DISPLAY
1988 DESCRIPTION:REMINDER
1989 TRIGGER;RELATED=START:-PT15M
1990 END:VALARM
1991 END:VEVENT
1992 END:VCALENDAR"
1993 nil
1994 "&15/5/2012 15:00-15:30 Query
1995 Location: phone
1996 Organizer: MAILTO:a.luser@foo.com
1997 Status: CONFIRMED
1998 Class: PUBLIC
1999 UID: 040000008200E00074C5B7101A82E0080000000020FFAED0CFEFCC01000000000000000010000000575268034ECDB649A15349B1BF240F15
2000 " nil)
2001 )
2002
2003 (provide 'icalendar-tests)
2004 ;;; icalendar-tests.el ends here