58b8379bb11073518fc1b545615d8f81341dba7e
[bpt/emacs.git] / test / automated / icalendar-tests.el
1 ;; icalendar-tests.el --- Test suite for icalendar.el
2
3 ;; Copyright (C) 2005, 2008-2012 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 (cadr (current-time-zone)))
432 (calendar-date-style 'iso)
433 (icalendar-recurring-start-year 2000))
434 (unwind-protect
435 (progn
436 (set-time-zone-rule "CET")
437 (when input-iso
438 (let ((calendar-month-name-array
439 ["January" "February" "March" "April" "May" "June" "July" "August"
440 "September" "October" "November" "December"])
441 (calendar-day-name-array
442 ["Sunday" "Monday" "Tuesday" "Wednesday" "Thursday" "Friday"
443 "Saturday"]))
444 (setq calendar-date-style 'iso)
445 (icalendar-tests--do-test-export input-iso expected-output)))
446 (when input-european
447 (let ((calendar-month-name-array
448 ["Januar" "Februar" "März" "April" "Mai" "Juni" "Juli" "August"
449 "September" "Oktober" "November" "Dezember"])
450 (calendar-day-name-array
451 ["Sonntag" "Montag" "Dienstag" "Mittwoch" "Donnerstag" "Freitag"
452 "Samstag"]))
453 (setq calendar-date-style 'european)
454 (icalendar-tests--do-test-export input-european expected-output)))
455 (when input-american
456 (let ((calendar-month-name-array
457 ["January" "February" "March" "April" "May" "June" "July" "August"
458 "September" "October" "November" "December"])
459 (calendar-day-name-array
460 ["Sunday" "Monday" "Tuesday" "Wednesday" "Thursday" "Friday"
461 "Saturday"]))
462 (setq calendar-date-style 'american)
463 (icalendar-tests--do-test-export input-american expected-output))))
464 ;; restore time-zone if something went terribly wrong
465 (set-time-zone-rule tz))))
466
467 (defun icalendar-tests--do-test-export (input expected-output)
468 "Actually perform export test.
469 Argument INPUT input diary string.
470 Argument EXPECTED-OUTPUT expected iCalendar result string."
471 (let ((temp-file (make-temp-file "icalendar-tests-ics")))
472 (unwind-protect
473 (progn
474 (with-temp-buffer
475 (insert input)
476 (icalendar-export-region (point-min) (point-max) temp-file))
477 (save-excursion
478 (find-file temp-file)
479 (goto-char (point-min))
480 (cond (expected-output
481 (should (re-search-forward "^\\s-*BEGIN:VCALENDAR
482 PRODID:-//Emacs//NONSGML icalendar.el//EN
483 VERSION:2.0
484 BEGIN:VEVENT
485 UID:emacs[0-9]+
486 \\(\\(.\\|\n\\)+\\)
487 END:VEVENT
488 END:VCALENDAR
489 \\s-*$"
490 nil t))
491 (should (string-match
492 (concat "^\\s-*"
493 (regexp-quote (buffer-substring-no-properties
494 (match-beginning 1) (match-end 1)))
495 "\\s-*$")
496 expected-output)))
497 (t
498 (should (re-search-forward "^\\s-*BEGIN:VCALENDAR
499 PRODID:-//Emacs//NONSGML icalendar.el//EN
500 VERSION:2.0
501 END:VCALENDAR
502 \\s-*$"
503 nil t))))))
504 ;; cleanup!!
505 (kill-buffer (find-buffer-visiting temp-file))
506 (delete-file temp-file))))
507
508 (ert-deftest icalendar-export-ordinary-no-time ()
509 "Perform export test."
510
511 (let ((icalendar-export-hidden-diary-entries nil))
512 (icalendar-tests--test-export
513 "&2000 Oct 3 ordinary no time "
514 "&3 Okt 2000 ordinary no time "
515 "&Oct 3 2000 ordinary no time "
516 nil))
517
518 (icalendar-tests--test-export
519 "2000 Oct 3 ordinary no time "
520 "3 Okt 2000 ordinary no time "
521 "Oct 3 2000 ordinary no time "
522 "DTSTART;VALUE=DATE:20001003
523 DTEND;VALUE=DATE:20001004
524 SUMMARY:ordinary no time
525 "))
526
527 (ert-deftest icalendar-export-ordinary ()
528 "Perform export test."
529
530 (icalendar-tests--test-export
531 "2000 Oct 3 16:30 ordinary with time"
532 "3 Okt 2000 16:30 ordinary with time"
533 "Oct 3 2000 16:30 ordinary with time"
534 "DTSTART;VALUE=DATE-TIME:20001003T163000
535 DTEND;VALUE=DATE-TIME:20001003T173000
536 SUMMARY:ordinary with time
537 ")
538 (icalendar-tests--test-export
539 "2000 10 3 16:30 ordinary with time 2"
540 "3 10 2000 16:30 ordinary with time 2"
541 "10 3 2000 16:30 ordinary with time 2"
542 "DTSTART;VALUE=DATE-TIME:20001003T163000
543 DTEND;VALUE=DATE-TIME:20001003T173000
544 SUMMARY:ordinary with time 2
545 ")
546
547 (icalendar-tests--test-export
548 "2000/10/3 16:30 ordinary with time 3"
549 "3/10/2000 16:30 ordinary with time 3"
550 "10/3/2000 16:30 ordinary with time 3"
551 "DTSTART;VALUE=DATE-TIME:20001003T163000
552 DTEND;VALUE=DATE-TIME:20001003T173000
553 SUMMARY:ordinary with time 3
554 "))
555
556 (ert-deftest icalendar-export-multiline ()
557 "Perform export test."
558
559 ;; multiline -- FIXME!!!
560 (icalendar-tests--test-export
561 "2000 October 3 16:30 multiline
562 17:30 multiline continued FIXME"
563 "3 Oktober 2000 16:30 multiline
564 17:30 multiline continued FIXME"
565 "October 3 2000 16:30 multiline
566 17:30 multiline continued FIXME"
567 "DTSTART;VALUE=DATE-TIME:20001003T163000
568 DTEND;VALUE=DATE-TIME:20001003T173000
569 SUMMARY:multiline
570 DESCRIPTION:
571 17:30 multiline continued FIXME
572 "))
573
574 (ert-deftest icalendar-export-weekly-by-day ()
575 "Perform export test."
576
577 ;; weekly by day
578 (icalendar-tests--test-export
579 "Monday 1:30pm weekly by day with start time"
580 "Montag 13:30 weekly by day with start time"
581 "Monday 1:30pm weekly by day with start time"
582 "DTSTART;VALUE=DATE-TIME:20000103T133000
583 DTEND;VALUE=DATE-TIME:20000103T143000
584 RRULE:FREQ=WEEKLY;INTERVAL=1;BYDAY=MO
585 SUMMARY:weekly by day with start time
586 ")
587
588 (icalendar-tests--test-export
589 "Monday 13:30-15:00 weekly by day with start and end time"
590 "Montag 13:30-15:00 weekly by day with start and end time"
591 "Monday 01:30pm-03:00pm weekly by day with start and end time"
592 "DTSTART;VALUE=DATE-TIME:20000103T133000
593 DTEND;VALUE=DATE-TIME:20000103T150000
594 RRULE:FREQ=WEEKLY;INTERVAL=1;BYDAY=MO
595 SUMMARY:weekly by day with start and end time
596 "))
597
598 (ert-deftest icalendar-export-yearly ()
599 "Perform export test."
600 ;; yearly
601 (icalendar-tests--test-export
602 "may 1 yearly no time"
603 "1 Mai yearly no time"
604 "may 1 yearly no time"
605 "DTSTART;VALUE=DATE:19000501
606 DTEND;VALUE=DATE:19000502
607 RRULE:FREQ=YEARLY;INTERVAL=1;BYMONTH=5;BYMONTHDAY=1
608 SUMMARY:yearly no time
609 "))
610
611 (ert-deftest icalendar-export-anniversary ()
612 "Perform export test."
613 ;; anniversaries
614 (icalendar-tests--test-export
615 "%%(diary-anniversary 1989 10 3) anniversary no time"
616 "%%(diary-anniversary 3 10 1989) anniversary no time"
617 "%%(diary-anniversary 10 3 1989) anniversary no time"
618 "DTSTART;VALUE=DATE:19891003
619 DTEND;VALUE=DATE:19891004
620 RRULE:FREQ=YEARLY;INTERVAL=1;BYMONTH=10;BYMONTHDAY=03
621 SUMMARY:anniversary no time
622 ")
623 (icalendar-tests--test-export
624 "%%(diary-anniversary 1989 10 3) 19:00-20:00 anniversary with time"
625 "%%(diary-anniversary 3 10 1989) 19:00-20:00 anniversary with time"
626 "%%(diary-anniversary 10 3 1989) 19:00-20:00 anniversary with time"
627 "DTSTART;VALUE=DATE-TIME:19891003T190000
628 DTEND;VALUE=DATE-TIME:19891004T200000
629 RRULE:FREQ=YEARLY;INTERVAL=1;BYMONTH=10;BYMONTHDAY=03
630 SUMMARY:anniversary with time
631 "))
632
633 (ert-deftest icalendar-export-block ()
634 "Perform export test."
635 ;; block
636 (icalendar-tests--test-export
637 "%%(diary-block 2001 6 18 2001 7 6) block no time"
638 "%%(diary-block 18 6 2001 6 7 2001) block no time"
639 "%%(diary-block 6 18 2001 7 6 2001) block no time"
640 "DTSTART;VALUE=DATE:20010618
641 DTEND;VALUE=DATE:20010707
642 SUMMARY:block no time
643 ")
644 (icalendar-tests--test-export
645 "%%(diary-block 2001 6 18 2001 7 6) 13:00-17:00 block with time"
646 "%%(diary-block 18 6 2001 6 7 2001) 13:00-17:00 block with time"
647 "%%(diary-block 6 18 2001 7 6 2001) 13:00-17:00 block with time"
648 "DTSTART;VALUE=DATE-TIME:20010618T130000
649 DTEND;VALUE=DATE-TIME:20010618T170000
650 RRULE:FREQ=DAILY;INTERVAL=1;UNTIL=20010706
651 SUMMARY:block with time
652 ")
653 (icalendar-tests--test-export
654 "%%(diary-block 2001 6 18 2001 7 6) 13:00 block no end time"
655 "%%(diary-block 18 6 2001 6 7 2001) 13:00 block no end time"
656 "%%(diary-block 6 18 2001 7 6 2001) 13:00 block no end time"
657 "DTSTART;VALUE=DATE-TIME:20010618T130000
658 DTEND;VALUE=DATE-TIME:20010618T140000
659 RRULE:FREQ=DAILY;INTERVAL=1;UNTIL=20010706
660 SUMMARY:block no end time
661 "))
662
663 ;; ======================================================================
664 ;; Import tests
665 ;; ======================================================================
666
667 (defun icalendar-tests--test-import (input expected-iso expected-european
668 expected-american)
669 "Perform import test.
670 Argument INPUT icalendar event string.
671 Argument EXPECTED-ISO expected iso style diary string.
672 Argument EXPECTED-EUROPEAN expected european style diary string.
673 Argument EXPECTED-AMERICAN expected american style diary string."
674 (let ((timezone (cadr (current-time-zone))))
675 (set-time-zone-rule "CET")
676 (with-temp-buffer
677 (if (string-match "^BEGIN:VCALENDAR" input)
678 (insert input)
679 (insert "BEGIN:VCALENDAR\nPRODID:-//Emacs//NONSGML icalendar.el//EN\n")
680 (insert "VERSION:2.0\nBEGIN:VEVENT\n")
681 (insert input)
682 (unless (eq (char-before) ?\n)
683 (insert "\n"))
684 (insert "END:VEVENT\nEND:VCALENDAR\n"))
685 (let ((icalendar-import-format "%s%d%l%o%t%u%c%U")
686 (icalendar-import-format-summary "%s")
687 (icalendar-import-format-location "\n Location: %s")
688 (icalendar-import-format-description "\n Desc: %s")
689 (icalendar-import-format-organizer "\n Organizer: %s")
690 (icalendar-import-format-status "\n Status: %s")
691 (icalendar-import-format-url "\n URL: %s")
692 (icalendar-import-format-class "\n Class: %s")
693 (icalendar-import-format-uid "\n UID: %s")
694 calendar-date-style)
695 (when expected-iso
696 (setq calendar-date-style 'iso)
697 (icalendar-tests--do-test-import input expected-iso))
698 (when expected-european
699 (setq calendar-date-style 'european)
700 (icalendar-tests--do-test-import input expected-european))
701 (when expected-american
702 (setq calendar-date-style 'american)
703 (icalendar-tests--do-test-import input expected-american))))
704 (set-time-zone-rule timezone)))
705
706 (defun icalendar-tests--do-test-import (input expected-output)
707 "Actually perform import test.
708 Argument INPUT input icalendar string.
709 Argument EXPECTED-OUTPUT expected diary string."
710 (let ((temp-file (make-temp-file "icalendar-test-diary")))
711 (icalendar-import-buffer temp-file t t)
712 (save-excursion
713 (find-file temp-file)
714 (let ((result (buffer-substring-no-properties (point-min) (point-max))))
715 (should (string= expected-output result)))
716 (kill-buffer (find-buffer-visiting temp-file))
717 (delete-file temp-file))))
718
719 (ert-deftest icalendar-import-non-recurring ()
720 "Perform standard import tests."
721 (icalendar-tests--test-import
722 "SUMMARY:non-recurring
723 DTSTART;VALUE=DATE-TIME:20030919T090000
724 DTEND;VALUE=DATE-TIME:20030919T113000"
725 "&2003/9/19 09:00-11:30 non-recurring\n"
726 "&19/9/2003 09:00-11:30 non-recurring\n"
727 "&9/19/2003 09:00-11:30 non-recurring\n")
728 (icalendar-tests--test-import
729 "SUMMARY:non-recurring allday
730 DTSTART;VALUE=DATE-TIME:20030919"
731 "&2003/9/19 non-recurring allday\n"
732 "&19/9/2003 non-recurring allday\n"
733 "&9/19/2003 non-recurring allday\n")
734 (icalendar-tests--test-import
735 ;; Checkdoc removes trailing blanks. Therefore: format!
736 (format "%s\n%s\n%s" "SUMMARY:long " " summary"
737 "DTSTART;VALUE=DATE:20030919")
738 "&2003/9/19 long summary\n"
739 "&19/9/2003 long summary\n"
740 "&9/19/2003 long summary\n")
741 (icalendar-tests--test-import
742 "UID:748f2da0-0d9b-11d8-97af-b4ec8686ea61
743 SUMMARY:Sommerferien
744 STATUS:TENTATIVE
745 CLASS:PRIVATE
746 X-MOZILLA-ALARM-DEFAULT-UNITS:Minuten
747 X-MOZILLA-RECUR-DEFAULT-INTERVAL:0
748 DTSTART;VALUE=DATE:20040719
749 DTEND;VALUE=DATE:20040828
750 DTSTAMP:20031103T011641Z
751 "
752 "&%%(and (diary-block 2004 7 19 2004 8 27)) Sommerferien
753 Status: TENTATIVE
754 Class: PRIVATE
755 UID: 748f2da0-0d9b-11d8-97af-b4ec8686ea61
756 "
757 "&%%(and (diary-block 19 7 2004 27 8 2004)) Sommerferien
758 Status: TENTATIVE
759 Class: PRIVATE
760 UID: 748f2da0-0d9b-11d8-97af-b4ec8686ea61
761 "
762 "&%%(and (diary-block 7 19 2004 8 27 2004)) Sommerferien
763 Status: TENTATIVE
764 Class: PRIVATE
765 UID: 748f2da0-0d9b-11d8-97af-b4ec8686ea61
766 ")
767 (icalendar-tests--test-import
768 "UID
769 :04979712-3902-11d9-93dd-8f9f4afe08da
770 SUMMARY
771 :folded summary
772 STATUS
773 :TENTATIVE
774 CLASS
775 :PRIVATE
776 X-MOZILLA-ALARM-DEFAULT-LENGTH
777 :0
778 DTSTART
779 :20041123T140000
780 DTEND
781 :20041123T143000
782 DTSTAMP
783 :20041118T013430Z
784 LAST-MODIFIED
785 :20041118T013640Z
786 "
787 "&2004/11/23 14:00-14:30 folded summary
788 Status: TENTATIVE
789 Class: PRIVATE
790 UID: 04979712-3902-11d9-93dd-8f9f4afe08da\n"
791 "&23/11/2004 14:00-14:30 folded summary
792 Status: TENTATIVE
793 Class: PRIVATE
794 UID: 04979712-3902-11d9-93dd-8f9f4afe08da\n"
795 "&11/23/2004 14:00-14:30 folded summary
796 Status: TENTATIVE
797 Class: PRIVATE
798 UID: 04979712-3902-11d9-93dd-8f9f4afe08da\n")
799
800 (icalendar-tests--test-import
801 "UID
802 :6161a312-3902-11d9-b512-f764153bb28b
803 SUMMARY
804 :another example
805 STATUS
806 :TENTATIVE
807 CLASS
808 :PRIVATE
809 X-MOZILLA-ALARM-DEFAULT-LENGTH
810 :0
811 DTSTART
812 :20041123T144500
813 DTEND
814 :20041123T154500
815 DTSTAMP
816 :20041118T013641Z
817 "
818 "&2004/11/23 14:45-15:45 another example
819 Status: TENTATIVE
820 Class: PRIVATE
821 UID: 6161a312-3902-11d9-b512-f764153bb28b\n"
822 "&23/11/2004 14:45-15:45 another example
823 Status: TENTATIVE
824 Class: PRIVATE
825 UID: 6161a312-3902-11d9-b512-f764153bb28b\n"
826 "&11/23/2004 14:45-15:45 another example
827 Status: TENTATIVE
828 Class: PRIVATE
829 UID: 6161a312-3902-11d9-b512-f764153bb28b\n"))
830
831 (ert-deftest icalendar-import-rrule ()
832 (icalendar-tests--test-import
833 "SUMMARY:rrule daily
834 DTSTART;VALUE=DATE-TIME:20030919T090000
835 DTEND;VALUE=DATE-TIME:20030919T113000
836 RRULE:FREQ=DAILY;
837 "
838 "&%%(and (diary-cyclic 1 2003 9 19)) 09:00-11:30 rrule daily\n"
839 "&%%(and (diary-cyclic 1 19 9 2003)) 09:00-11:30 rrule daily\n"
840 "&%%(and (diary-cyclic 1 9 19 2003)) 09:00-11:30 rrule daily\n")
841 ;; RRULE examples
842 (icalendar-tests--test-import
843 "SUMMARY:rrule daily
844 DTSTART;VALUE=DATE-TIME:20030919T090000
845 DTEND;VALUE=DATE-TIME:20030919T113000
846 RRULE:FREQ=DAILY;INTERVAL=2
847 "
848 "&%%(and (diary-cyclic 2 2003 9 19)) 09:00-11:30 rrule daily\n"
849 "&%%(and (diary-cyclic 2 19 9 2003)) 09:00-11:30 rrule daily\n"
850 "&%%(and (diary-cyclic 2 9 19 2003)) 09:00-11:30 rrule daily\n")
851 (icalendar-tests--test-import
852 "SUMMARY:rrule daily with exceptions
853 DTSTART;VALUE=DATE-TIME:20030919T090000
854 DTEND;VALUE=DATE-TIME:20030919T113000
855 RRULE:FREQ=DAILY;INTERVAL=2
856 EXDATE:20030921,20030925
857 "
858 "&%%(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"
859 "&%%(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"
860 "&%%(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")
861 (icalendar-tests--test-import
862 "SUMMARY:rrule weekly
863 DTSTART;VALUE=DATE-TIME:20030919T090000
864 DTEND;VALUE=DATE-TIME:20030919T113000
865 RRULE:FREQ=WEEKLY;
866 "
867 "&%%(and (diary-cyclic 7 2003 9 19)) 09:00-11:30 rrule weekly\n"
868 "&%%(and (diary-cyclic 7 19 9 2003)) 09:00-11:30 rrule weekly\n"
869 "&%%(and (diary-cyclic 7 9 19 2003)) 09:00-11:30 rrule weekly\n")
870 (icalendar-tests--test-import
871 "SUMMARY:rrule monthly no end
872 DTSTART;VALUE=DATE-TIME:20030919T090000
873 DTEND;VALUE=DATE-TIME:20030919T113000
874 RRULE:FREQ=MONTHLY;
875 "
876 "&%%(and (diary-date t t 19) (diary-block 2003 9 19 9999 1 1)) 09:00-11:30 rrule monthly no end\n"
877 "&%%(and (diary-date 19 t t) (diary-block 19 9 2003 1 1 9999)) 09:00-11:30 rrule monthly no end\n"
878 "&%%(and (diary-date t 19 t) (diary-block 9 19 2003 1 1 9999)) 09:00-11:30 rrule monthly no end\n")
879 (icalendar-tests--test-import
880 "SUMMARY:rrule monthly with end
881 DTSTART;VALUE=DATE-TIME:20030919T090000
882 DTEND;VALUE=DATE-TIME:20030919T113000
883 RRULE:FREQ=MONTHLY;UNTIL=20050819;
884 "
885 "&%%(and (diary-date t t 19) (diary-block 2003 9 19 2005 8 19)) 09:00-11:30 rrule monthly with end\n"
886 "&%%(and (diary-date 19 t t) (diary-block 19 9 2003 19 8 2005)) 09:00-11:30 rrule monthly with end\n"
887 "&%%(and (diary-date t 19 t) (diary-block 9 19 2003 8 19 2005)) 09:00-11:30 rrule monthly with end\n")
888 (icalendar-tests--test-import
889 "DTSTART;VALUE=DATE:20040815
890 DTEND;VALUE=DATE:20040816
891 SUMMARY:Maria Himmelfahrt
892 RRULE:FREQ=YEARLY;INTERVAL=1;BYMONTH=8
893 "
894 "&%%(and (diary-anniversary 2004 8 15)) Maria Himmelfahrt\n"
895 "&%%(and (diary-anniversary 15 8 2004)) Maria Himmelfahrt\n"
896 "&%%(and (diary-anniversary 8 15 2004)) Maria Himmelfahrt\n")
897 (icalendar-tests--test-import
898 "SUMMARY:rrule yearly
899 DTSTART;VALUE=DATE-TIME:20030919T090000
900 DTEND;VALUE=DATE-TIME:20030919T113000
901 RRULE:FREQ=YEARLY;INTERVAL=2
902 "
903 "&%%(and (diary-anniversary 2003 9 19)) 09:00-11:30 rrule yearly\n" ;FIXME
904 "&%%(and (diary-anniversary 19 9 2003)) 09:00-11:30 rrule yearly\n" ;FIXME
905 "&%%(and (diary-anniversary 9 19 2003)) 09:00-11:30 rrule yearly\n") ;FIXME
906 (icalendar-tests--test-import
907 "SUMMARY:rrule count daily short
908 DTSTART;VALUE=DATE-TIME:20030919T090000
909 DTEND;VALUE=DATE-TIME:20030919T113000
910 RRULE:FREQ=DAILY;COUNT=1;INTERVAL=1
911 "
912 "&%%(and (diary-cyclic 1 2003 9 19) (diary-block 2003 9 19 2003 9 19)) 09:00-11:30 rrule count daily short\n"
913 "&%%(and (diary-cyclic 1 19 9 2003) (diary-block 19 9 2003 19 9 2003)) 09:00-11:30 rrule count daily short\n"
914 "&%%(and (diary-cyclic 1 9 19 2003) (diary-block 9 19 2003 9 19 2003)) 09:00-11:30 rrule count daily short\n")
915 (icalendar-tests--test-import
916 "SUMMARY:rrule count daily long
917 DTSTART;VALUE=DATE-TIME:20030919T090000
918 DTEND;VALUE=DATE-TIME:20030919T113000
919 RRULE:FREQ=DAILY;COUNT=14;INTERVAL=1
920 "
921 "&%%(and (diary-cyclic 1 2003 9 19) (diary-block 2003 9 19 2003 10 2)) 09:00-11:30 rrule count daily long\n"
922 "&%%(and (diary-cyclic 1 19 9 2003) (diary-block 19 9 2003 2 10 2003)) 09:00-11:30 rrule count daily long\n"
923 "&%%(and (diary-cyclic 1 9 19 2003) (diary-block 9 19 2003 10 2 2003)) 09:00-11:30 rrule count daily long\n")
924 (icalendar-tests--test-import
925 "SUMMARY:rrule count bi-weekly 3 times
926 DTSTART;VALUE=DATE-TIME:20030919T090000
927 DTEND;VALUE=DATE-TIME:20030919T113000
928 RRULE:FREQ=WEEKLY;COUNT=3;INTERVAL=2
929 "
930 "&%%(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"
931 "&%%(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"
932 "&%%(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")
933 (icalendar-tests--test-import
934 "SUMMARY:rrule count monthly
935 DTSTART;VALUE=DATE-TIME:20030919T090000
936 DTEND;VALUE=DATE-TIME:20030919T113000
937 RRULE:FREQ=MONTHLY;INTERVAL=1;COUNT=5
938 "
939 "&%%(and (diary-date t t 19) (diary-block 2003 9 19 2004 1 19)) 09:00-11:30 rrule count monthly\n"
940 "&%%(and (diary-date 19 t t) (diary-block 19 9 2003 19 1 2004)) 09:00-11:30 rrule count monthly\n"
941 "&%%(and (diary-date t 19 t) (diary-block 9 19 2003 1 19 2004)) 09:00-11:30 rrule count monthly\n")
942 (icalendar-tests--test-import
943 "SUMMARY:rrule count every second month
944 DTSTART;VALUE=DATE-TIME:20030919T090000
945 DTEND;VALUE=DATE-TIME:20030919T113000
946 RRULE:FREQ=MONTHLY;INTERVAL=2;COUNT=5
947 "
948 "&%%(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
949 "&%%(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
950 "&%%(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
951 (icalendar-tests--test-import
952 "SUMMARY:rrule count yearly
953 DTSTART;VALUE=DATE-TIME:20030919T090000
954 DTEND;VALUE=DATE-TIME:20030919T113000
955 RRULE:FREQ=YEARLY;INTERVAL=1;COUNT=5
956 "
957 "&%%(and (diary-date t 9 19) (diary-block 2003 9 19 2007 9 19)) 09:00-11:30 rrule count yearly\n"
958 "&%%(and (diary-date 19 9 t) (diary-block 19 9 2003 19 9 2007)) 09:00-11:30 rrule count yearly\n"
959 "&%%(and (diary-date 9 19 t) (diary-block 9 19 2003 9 19 2007)) 09:00-11:30 rrule count yearly\n")
960 (icalendar-tests--test-import
961 "SUMMARY:rrule count every second year
962 DTSTART;VALUE=DATE-TIME:20030919T090000
963 DTEND;VALUE=DATE-TIME:20030919T113000
964 RRULE:FREQ=YEARLY;INTERVAL=2;COUNT=5
965 "
966 "&%%(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!!!
967 "&%%(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!!!
968 "&%%(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!!!
969 )
970
971 (ert-deftest icalendar-import-duration ()
972 ;; duration
973 (icalendar-tests--test-import
974 "DTSTART;VALUE=DATE:20050217
975 SUMMARY:duration
976 DURATION:P7D
977 "
978 "&%%(and (diary-block 2005 2 17 2005 2 23)) duration\n"
979 "&%%(and (diary-block 17 2 2005 23 2 2005)) duration\n"
980 "&%%(and (diary-block 2 17 2005 2 23 2005)) duration\n")
981 (icalendar-tests--test-import
982 "UID:20041127T183329Z-18215-1001-4536-49109@andromeda
983 DTSTAMP:20041127T183315Z
984 LAST-MODIFIED:20041127T183329
985 SUMMARY:Urlaub
986 DTSTART;VALUE=DATE:20011221
987 DTEND;VALUE=DATE:20011221
988 RRULE:FREQ=DAILY;UNTIL=20011229;INTERVAL=1;WKST=SU
989 CLASS:PUBLIC
990 SEQUENCE:1
991 CREATED:20041127T183329
992 "
993 "&%%(and (diary-cyclic 1 2001 12 21) (diary-block 2001 12 21 2001 12 29)) Urlaub
994 Class: PUBLIC
995 UID: 20041127T183329Z-18215-1001-4536-49109@andromeda\n"
996 "&%%(and (diary-cyclic 1 21 12 2001) (diary-block 21 12 2001 29 12 2001)) Urlaub
997 Class: PUBLIC
998 UID: 20041127T183329Z-18215-1001-4536-49109@andromeda\n"
999 "&%%(and (diary-cyclic 1 12 21 2001) (diary-block 12 21 2001 12 29 2001)) Urlaub
1000 Class: PUBLIC
1001 UID: 20041127T183329Z-18215-1001-4536-49109@andromeda\n"))
1002
1003 (ert-deftest icalendar-import-bug-6766 ()
1004 ;;bug#6766 -- multiple byday values in a weekly rrule
1005 (icalendar-tests--test-import
1006 "CLASS:PUBLIC
1007 DTEND;TZID=America/New_York:20100421T120000
1008 DTSTAMP:20100525T141214Z
1009 DTSTART;TZID=America/New_York:20100421T113000
1010 RRULE:FREQ=WEEKLY;INTERVAL=1;BYDAY=MO,WE,TH,FR
1011 SEQUENCE:1
1012 STATUS:CONFIRMED
1013 SUMMARY:Scrum
1014 TRANSP:OPAQUE
1015 UID:8814e3f9-7482-408f-996c-3bfe486a1262
1016 END:VEVENT
1017 BEGIN:VEVENT
1018 CLASS:PUBLIC
1019 DTSTAMP:20100525T141214Z
1020 DTSTART;VALUE=DATE:20100422
1021 DTEND;VALUE=DATE:20100423
1022 RRULE:FREQ=WEEKLY;INTERVAL=1;BYDAY=TU,TH
1023 SEQUENCE:1
1024 SUMMARY:Tues + Thurs thinking
1025 TRANSP:OPAQUE
1026 UID:8814e3f9-7482-408f-996c-3bfe486a1263
1027 "
1028 "&%%(and (memq (calendar-day-of-week date) '(1 3 4 5)) (diary-cyclic 1 2010 4 21)) 11:30-12:00 Scrum
1029 Status: CONFIRMED
1030 Class: PUBLIC
1031 UID: 8814e3f9-7482-408f-996c-3bfe486a1262
1032 &%%(and (memq (calendar-day-of-week date) '(2 4)) (diary-cyclic 1 2010 4 22)) Tues + Thurs thinking
1033 Class: PUBLIC
1034 UID: 8814e3f9-7482-408f-996c-3bfe486a1263
1035 "
1036 "&%%(and (memq (calendar-day-of-week date) '(1 3 4 5)) (diary-cyclic 1 21 4 2010)) 11:30-12:00 Scrum
1037 Status: CONFIRMED
1038 Class: PUBLIC
1039 UID: 8814e3f9-7482-408f-996c-3bfe486a1262
1040 &%%(and (memq (calendar-day-of-week date) '(2 4)) (diary-cyclic 1 22 4 2010)) Tues + Thurs thinking
1041 Class: PUBLIC
1042 UID: 8814e3f9-7482-408f-996c-3bfe486a1263
1043 "
1044 "&%%(and (memq (calendar-day-of-week date) '(1 3 4 5)) (diary-cyclic 1 4 21 2010)) 11:30-12:00 Scrum
1045 Status: CONFIRMED
1046 Class: PUBLIC
1047 UID: 8814e3f9-7482-408f-996c-3bfe486a1262
1048 &%%(and (memq (calendar-day-of-week date) '(2 4)) (diary-cyclic 1 4 22 2010)) Tues + Thurs thinking
1049 Class: PUBLIC
1050 UID: 8814e3f9-7482-408f-996c-3bfe486a1263
1051 "))
1052
1053 (ert-deftest icalendar-import-multiple-vcalendars ()
1054 (icalendar-tests--test-import
1055 "DTSTART;VALUE=DATE:20110723
1056 SUMMARY:event-1
1057 "
1058 "&2011/7/23 event-1\n"
1059 "&23/7/2011 event-1\n"
1060 "&7/23/2011 event-1\n")
1061
1062 (icalendar-tests--test-import
1063 "BEGIN:VCALENDAR
1064 PRODID:-//Emacs//NONSGML icalendar.el//EN
1065 VERSION:2.0\nBEGIN:VEVENT
1066 DTSTART;VALUE=DATE:20110723
1067 SUMMARY:event-1
1068 END:VEVENT
1069 END:VCALENDAR
1070 BEGIN:VCALENDAR
1071 PRODID:-//Emacs//NONSGML icalendar.el//EN
1072 VERSION:2.0
1073 BEGIN:VEVENT
1074 DTSTART;VALUE=DATE:20110724
1075 SUMMARY:event-2
1076 END:VEVENT
1077 END:VCALENDAR
1078 BEGIN:VCALENDAR
1079 PRODID:-//Emacs//NONSGML icalendar.el//EN
1080 VERSION:2.0
1081 BEGIN:VEVENT
1082 DTSTART;VALUE=DATE:20110725
1083 SUMMARY:event-3a
1084 END:VEVENT
1085 BEGIN:VEVENT
1086 DTSTART;VALUE=DATE:20110725
1087 SUMMARY:event-3b
1088 END:VEVENT
1089 END:VCALENDAR
1090 "
1091 "&2011/7/23 event-1\n&2011/7/24 event-2\n&2011/7/25 event-3a\n&2011/7/25 event-3b\n"
1092 "&23/7/2011 event-1\n&24/7/2011 event-2\n&25/7/2011 event-3a\n&25/7/2011 event-3b\n"
1093 "&7/23/2011 event-1\n&7/24/2011 event-2\n&7/25/2011 event-3a\n&7/25/2011 event-3b\n"))
1094
1095 (ert-deftest icalendar-import-with-uid ()
1096 "Perform import test with uid."
1097 (icalendar-tests--test-import
1098 "UID:1234567890uid
1099 SUMMARY:non-recurring
1100 DTSTART;VALUE=DATE-TIME:20030919T090000
1101 DTEND;VALUE=DATE-TIME:20030919T113000"
1102 "&2003/9/19 09:00-11:30 non-recurring\n UID: 1234567890uid\n"
1103 "&19/9/2003 09:00-11:30 non-recurring\n UID: 1234567890uid\n"
1104 "&9/19/2003 09:00-11:30 non-recurring\n UID: 1234567890uid\n"))
1105
1106 (ert-deftest icalendar-import-with-timezone ()
1107 ;; bug#11473
1108 (icalendar-tests--test-import
1109 "BEGIN:VCALENDAR
1110 BEGIN:VTIMEZONE
1111 TZID:fictional\, nonexistent\, arbitrary
1112 BEGIN:STANDARD
1113 DTSTART:20100101T000000
1114 TZOFFSETFROM:+0200
1115 TZOFFSETTO:-0200
1116 RRULE:FREQ=YEARLY;INTERVAL=1;BYDAY=1SU;BYMONTH=01
1117 END:STANDARD
1118 BEGIN:DAYLIGHT
1119 DTSTART:20101201T000000
1120 TZOFFSETFROM:-0200
1121 TZOFFSETTO:+0200
1122 RRULE:FREQ=YEARLY;INTERVAL=1;BYDAY=1SU;BYMONTH=11
1123 END:DAYLIGHT
1124 END:VTIMEZONE
1125 BEGIN:VEVENT
1126 SUMMARY:standardtime
1127 DTSTART;TZID=\"fictional, nonexistent, arbitrary\":20120115T120000
1128 DTEND;TZID=\"fictional, nonexistent, arbitrary\":20120115T123000
1129 END:VEVENT
1130 BEGIN:VEVENT
1131 SUMMARY:daylightsavingtime
1132 DTSTART;TZID=\"fictional, nonexistent, arbitrary\":20121215T120000
1133 DTEND;TZID=\"fictional, nonexistent, arbitrary\":20121215T123000
1134 END:VEVENT
1135 END:VCALENDAR"
1136 ;; "standardtime" begins first sunday in january and is 4 hours behind CET
1137 ;; "daylightsavingtime" begins first sunday in november and is 1 hour before CET
1138 "&2012/1/15 15:00-15:30 standardtime
1139 &2012/12/15 11:00-11:30 daylightsavingtime
1140 "
1141 nil
1142 nil)
1143 )
1144 ;; ======================================================================
1145 ;; Cycle
1146 ;; ======================================================================
1147 (defun icalendar-tests--test-cycle (input)
1148 "Perform cycle test.
1149 Argument INPUT icalendar event string."
1150 (with-temp-buffer
1151 (if (string-match "^BEGIN:VCALENDAR" input)
1152 (insert input)
1153 (insert "BEGIN:VCALENDAR\nPRODID:-//Emacs//NONSGML icalendar.el//EN\n")
1154 (insert "VERSION:2.0\nBEGIN:VEVENT\n")
1155 (insert input)
1156 (unless (eq (char-before) ?\n)
1157 (insert "\n"))
1158 (insert "END:VEVENT\nEND:VCALENDAR\n"))
1159 (let ((icalendar-import-format "%s%d%l%o%t%u%c%U")
1160 (icalendar-import-format-summary "%s")
1161 (icalendar-import-format-location "\n Location: %s")
1162 (icalendar-import-format-description "\n Desc: %s")
1163 (icalendar-import-format-organizer "\n Organizer: %s")
1164 (icalendar-import-format-status "\n Status: %s")
1165 (icalendar-import-format-url "\n URL: %s")
1166 (icalendar-import-format-class "\n Class: %s")
1167 (icalendar-import-format-class "\n UID: %s"))
1168 (dolist (calendar-date-style '(iso european american))
1169 (icalendar-tests--do-test-cycle)))))
1170
1171 (defun icalendar-tests--do-test-cycle ()
1172 "Actually perform import/export cycle test."
1173 (let ((temp-diary (make-temp-file "icalendar-test-diary"))
1174 (temp-ics (make-temp-file "icalendar-test-ics"))
1175 (org-input (buffer-substring-no-properties (point-min) (point-max))))
1176
1177 (unwind-protect
1178 (progn
1179 ;; step 1: import
1180 (icalendar-import-buffer temp-diary t t)
1181
1182 ;; step 2: export what was just imported
1183 (save-excursion
1184 (find-file temp-diary)
1185 (icalendar-export-region (point-min) (point-max) temp-ics))
1186
1187 ;; compare the output of step 2 with the input of step 1
1188 (save-excursion
1189 (find-file temp-ics)
1190 (goto-char (point-min))
1191 ;;(when (re-search-forward "\nUID:.*\n" nil t)
1192 ;;(replace-match "\n"))
1193 (let ((cycled (buffer-substring-no-properties (point-min) (point-max))))
1194 (should (string= org-input cycled)))))
1195 ;; clean up
1196 (kill-buffer (find-buffer-visiting temp-diary))
1197 (save-excursion
1198 (set-buffer (find-buffer-visiting temp-ics))
1199 (set-buffer-modified-p nil)
1200 (kill-buffer (current-buffer)))
1201 (delete-file temp-diary)
1202 (delete-file temp-ics))))
1203
1204 (ert-deftest icalendar-cycle ()
1205 "Perform cycling tests.
1206 Take care to avoid auto-generated UIDs here."
1207 (icalendar-tests--test-cycle
1208 "UID:dummyuid
1209 DTSTART;VALUE=DATE-TIME:20030919T090000
1210 DTEND;VALUE=DATE-TIME:20030919T113000
1211 SUMMARY:Cycletest
1212 ")
1213 (icalendar-tests--test-cycle
1214 "UID:blah
1215 DTSTART;VALUE=DATE-TIME:20030919T090000
1216 DTEND;VALUE=DATE-TIME:20030919T113000
1217 SUMMARY:Cycletest
1218 DESCRIPTION:beschreibung!
1219 LOCATION:nowhere
1220 ORGANIZER:ulf
1221 ")
1222 (icalendar-tests--test-cycle
1223 "UID:4711
1224 DTSTART;VALUE=DATE:19190909
1225 DTEND;VALUE=DATE:19190910
1226 RRULE:FREQ=YEARLY;INTERVAL=1;BYMONTH=09;BYMONTHDAY=09
1227 SUMMARY:and diary-anniversary
1228 "))
1229
1230 ;; ======================================================================
1231 ;; Real world
1232 ;; ======================================================================
1233 (ert-deftest icalendar-real-world ()
1234 "Perform real-world tests, as gathered from problem reports."
1235 ;; 2003-05-29
1236 (icalendar-tests--test-import
1237 "BEGIN:VCALENDAR
1238 METHOD:REQUEST
1239 PRODID:Microsoft CDO for Microsoft Exchange
1240 VERSION:2.0
1241 BEGIN:VTIMEZONE
1242 TZID:Kolkata\, Chennai\, Mumbai\, New Delhi
1243 X-MICROSOFT-CDO-TZID:23
1244 BEGIN:STANDARD
1245 DTSTART:16010101T000000
1246 TZOFFSETFROM:+0530
1247 TZOFFSETTO:+0530
1248 END:STANDARD
1249 BEGIN:DAYLIGHT
1250 DTSTART:16010101T000000
1251 TZOFFSETFROM:+0530
1252 TZOFFSETTO:+0530
1253 END:DAYLIGHT
1254 END:VTIMEZONE
1255 BEGIN:VEVENT
1256 DTSTAMP:20030509T043439Z
1257 DTSTART;TZID=\"Kolkata, Chennai, Mumbai, New Delhi\":20030509T103000
1258 SUMMARY:On-Site Interview
1259 UID:040000008200E00074C5B7101A82E0080000000080B6DE661216C301000000000000000
1260 010000000DB823520692542408ED02D7023F9DFF9
1261 ATTENDEE;ROLE=REQ-PARTICIPANT;PARTSTAT=NEEDS-ACTION;RSVP=TRUE;CN=\"Xxxxx
1262 xxx Xxxxxxxxxxxx\":MAILTO:xxxxxxxx@xxxxxxx.com
1263 ATTENDEE;ROLE=REQ-PARTICIPANT;PARTSTAT=NEEDS-ACTION;RSVP=TRUE;CN=\"Yyyyyyy Y
1264 yyyy\":MAILTO:yyyyyyy@yyyyyyy.com
1265 ATTENDEE;ROLE=REQ-PARTICIPANT;PARTSTAT=NEEDS-ACTION;RSVP=TRUE;CN=\"Zzzz Zzzz
1266 zz\":MAILTO:zzzzzz@zzzzzzz.com
1267 ORGANIZER;CN=\"Aaaaaa Aaaaa\":MAILTO:aaaaaaa@aaaaaaa.com
1268 LOCATION:Cccc
1269 DTEND;TZID=\"Kolkata, Chennai, Mumbai, New Delhi\":20030509T153000
1270 DESCRIPTION:10:30am - Blah
1271 SEQUENCE:0
1272 PRIORITY:5
1273 CLASS:
1274 CREATED:20030509T043439Z
1275 LAST-MODIFIED:20030509T043459Z
1276 STATUS:CONFIRMED
1277 TRANSP:OPAQUE
1278 X-MICROSOFT-CDO-BUSYSTATUS:BUSY
1279 X-MICROSOFT-CDO-INSTTYPE:0
1280 X-MICROSOFT-CDO-INTENDEDSTATUS:BUSY
1281 X-MICROSOFT-CDO-ALLDAYEVENT:FALSE
1282 X-MICROSOFT-CDO-IMPORTANCE:1
1283 X-MICROSOFT-CDO-OWNERAPPTID:126441427
1284 BEGIN:VALARM
1285 ACTION:DISPLAY
1286 DESCRIPTION:REMINDER
1287 TRIGGER;RELATED=START:-PT00H15M00S
1288 END:VALARM
1289 END:VEVENT
1290 END:VCALENDAR"
1291 nil
1292 "&9/5/2003 10:30-15:30 On-Site Interview
1293 Desc: 10:30am - Blah
1294 Location: Cccc
1295 Organizer: MAILTO:aaaaaaa@aaaaaaa.com
1296 Status: CONFIRMED
1297 UID: 040000008200E00074C5B7101A82E0080000000080B6DE661216C301000000000000000010000000DB823520692542408ED02D7023F9DFF9
1298 "
1299 "&5/9/2003 10:30-15:30 On-Site Interview
1300 Desc: 10:30am - Blah
1301 Location: Cccc
1302 Organizer: MAILTO:aaaaaaa@aaaaaaa.com
1303 Status: CONFIRMED
1304 UID: 040000008200E00074C5B7101A82E0080000000080B6DE661216C301000000000000000010000000DB823520692542408ED02D7023F9DFF9
1305 ")
1306
1307 ;; 2003-06-18 a
1308 (icalendar-tests--test-import
1309 "DTSTAMP:20030618T195512Z
1310 DTSTART;TZID=\"Mountain Time (US & Canada)\":20030623T110000
1311 SUMMARY:Dress Rehearsal for XXXX-XXXX
1312 UID:040000008200E00074C5B7101A82E00800000000608AA7DA9835C301000000000000000
1313 0100000007C3A6D65EE726E40B7F3D69A23BD567E
1314 ATTENDEE;ROLE=REQ-PARTICIPANT;PARTSTAT=NEEDS-ACTION;RSVP=TRUE;CN=\"AAAAA,AAA
1315 AA (A-AAAAAAA,ex1)\":MAILTO:aaaaa_aaaaa@aaaaa.com
1316 ORGANIZER;CN=\"ABCD,TECHTRAINING
1317 (A-Americas,exgen1)\":MAILTO:xxx@xxxxx.com
1318 LOCATION:555 or TN 555-5555 ID 5555 & NochWas (see below)
1319 DTEND;TZID=\"Mountain Time (US & Canada)\":20030623T120000
1320 DESCRIPTION:753 Zeichen hier radiert
1321 SEQUENCE:0
1322 PRIORITY:5
1323 CLASS:
1324 CREATED:20030618T195518Z
1325 LAST-MODIFIED:20030618T195527Z
1326 STATUS:CONFIRMED
1327 TRANSP:OPAQUE
1328 X-MICROSOFT-CDO-BUSYSTATUS:BUSY
1329 X-MICROSOFT-CDO-INSTTYPE:0
1330 X-MICROSOFT-CDO-INTENDEDSTATUS:BUSY
1331 X-MICROSOFT-CDO-ALLDAYEVENT:FALSE
1332 X-MICROSOFT-CDO-IMPORTANCE:1
1333 X-MICROSOFT-CDO-OWNERAPPTID:1022519251
1334 BEGIN:VALARM
1335 ACTION:DISPLAY
1336 DESCRIPTION:REMINDER
1337 TRIGGER;RELATED=START:-PT00H15M00S
1338 END:VALARM"
1339 nil
1340 "&23/6/2003 11:00-12:00 Dress Rehearsal for XXXX-XXXX
1341 Desc: 753 Zeichen hier radiert
1342 Location: 555 or TN 555-5555 ID 5555 & NochWas (see below)
1343 Organizer: MAILTO:xxx@xxxxx.com
1344 Status: CONFIRMED
1345 UID: 040000008200E00074C5B7101A82E00800000000608AA7DA9835C3010000000000000000100000007C3A6D65EE726E40B7F3D69A23BD567E
1346 "
1347 "&6/23/2003 11:00-12:00 Dress Rehearsal for XXXX-XXXX
1348 Desc: 753 Zeichen hier radiert
1349 Location: 555 or TN 555-5555 ID 5555 & NochWas (see below)
1350 Organizer: MAILTO:xxx@xxxxx.com
1351 Status: CONFIRMED
1352 UID: 040000008200E00074C5B7101A82E00800000000608AA7DA9835C3010000000000000000100000007C3A6D65EE726E40B7F3D69A23BD567E
1353 ")
1354 ;; 2003-06-18 b -- uses timezone
1355 (icalendar-tests--test-import
1356 "BEGIN:VCALENDAR
1357 METHOD:REQUEST
1358 PRODID:Microsoft CDO for Microsoft Exchange
1359 VERSION:2.0
1360 BEGIN:VTIMEZONE
1361 TZID:Mountain Time (US & Canada)
1362 X-MICROSOFT-CDO-TZID:12
1363 BEGIN:STANDARD
1364 DTSTART:16010101T020000
1365 TZOFFSETFROM:-0600
1366 TZOFFSETTO:-0700
1367 RRULE:FREQ=YEARLY;WKST=MO;INTERVAL=1;BYMONTH=10;BYDAY=-1SU
1368 END:STANDARD
1369 BEGIN:DAYLIGHT
1370 DTSTART:16010101T020000
1371 TZOFFSETFROM:-0700
1372 TZOFFSETTO:-0600
1373 RRULE:FREQ=YEARLY;WKST=MO;INTERVAL=1;BYMONTH=4;BYDAY=1SU
1374 END:DAYLIGHT
1375 END:VTIMEZONE
1376 BEGIN:VEVENT
1377 DTSTAMP:20030618T230323Z
1378 DTSTART;TZID=\"Mountain Time (US & Canada)\":20030623T090000
1379 SUMMARY:Updated: Dress Rehearsal for ABC01-15
1380 UID:040000008200E00074C5B7101A82E00800000000608AA7DA9835C301000000000000000
1381 0100000007C3A6D65EE726E40B7F3D69A23BD567E
1382 ATTENDEE;ROLE=REQ-PARTICIPANT;PARTSTAT=NEEDS-ACTION;X-REPLYTIME=20030618T20
1383 0700Z;RSVP=TRUE;CN=\"AAAAA,AAAAAA
1384 \(A-AAAAAAA,ex1)\":MAILTO:aaaaaa_aaaaa@aaaaa
1385 .com
1386 ORGANIZER;CN=\"ABCD,TECHTRAINING
1387 \(A-Americas,exgen1)\":MAILTO:bbb@bbbbb.com
1388 LOCATION:123 or TN 123-1234 ID abcd & SonstWo (see below)
1389 DTEND;TZID=\"Mountain Time (US & Canada)\":20030623T100000
1390 DESCRIPTION:Viele Zeichen standen hier früher
1391 SEQUENCE:0
1392 PRIORITY:5
1393 CLASS:
1394 CREATED:20030618T230326Z
1395 LAST-MODIFIED:20030618T230335Z
1396 STATUS:CONFIRMED
1397 TRANSP:OPAQUE
1398 X-MICROSOFT-CDO-BUSYSTATUS:BUSY
1399 X-MICROSOFT-CDO-INSTTYPE:0
1400 X-MICROSOFT-CDO-INTENDEDSTATUS:BUSY
1401 X-MICROSOFT-CDO-ALLDAYEVENT:FALSE
1402 X-MICROSOFT-CDO-IMPORTANCE:1
1403 X-MICROSOFT-CDO-OWNERAPPTID:1022519251
1404 BEGIN:VALARM
1405 ACTION:DISPLAY
1406 DESCRIPTION:REMINDER
1407 TRIGGER;RELATED=START:-PT00H15M00S
1408 END:VALARM
1409 END:VEVENT
1410 END:VCALENDAR"
1411 nil
1412 "&23/6/2003 17:00-18:00 Updated: Dress Rehearsal for ABC01-15
1413 Desc: Viele Zeichen standen hier früher
1414 Location: 123 or TN 123-1234 ID abcd & SonstWo (see below)
1415 Organizer: MAILTO:bbb@bbbbb.com
1416 Status: CONFIRMED
1417 UID: 040000008200E00074C5B7101A82E00800000000608AA7DA9835C3010000000000000000100000007C3A6D65EE726E40B7F3D69A23BD567E
1418 "
1419 "&6/23/2003 17:00-18:00 Updated: Dress Rehearsal for ABC01-15
1420 Desc: Viele Zeichen standen hier früher
1421 Location: 123 or TN 123-1234 ID abcd & SonstWo (see below)
1422 Organizer: MAILTO:bbb@bbbbb.com
1423 Status: CONFIRMED
1424 UID: 040000008200E00074C5B7101A82E00800000000608AA7DA9835C3010000000000000000100000007C3A6D65EE726E40B7F3D69A23BD567E
1425 ")
1426 ;; export 2004-10-28 block entries
1427 (icalendar-tests--test-export
1428 nil
1429 nil
1430 "-*- mode: text; fill-column: 256;-*-
1431
1432 >>> block entries:
1433
1434 %%(diary-block 11 8 2004 11 10 2004) Nov 8-10 aa
1435 "
1436 "DTSTART;VALUE=DATE:20041108
1437 DTEND;VALUE=DATE:20041111
1438 SUMMARY:Nov 8-10 aa")
1439
1440 (icalendar-tests--test-export
1441 nil
1442 nil
1443 "%%(diary-block 12 13 2004 12 17 2004) Dec 13-17 bb"
1444 "DTSTART;VALUE=DATE:20041213
1445 DTEND;VALUE=DATE:20041218
1446 SUMMARY:Dec 13-17 bb")
1447
1448 (icalendar-tests--test-export
1449 nil
1450 nil
1451 "%%(diary-block 2 3 2005 2 4 2005) Feb 3-4 cc"
1452 "DTSTART;VALUE=DATE:20050203
1453 DTEND;VALUE=DATE:20050205
1454 SUMMARY:Feb 3-4 cc")
1455
1456 (icalendar-tests--test-export
1457 nil
1458 nil
1459 "%%(diary-block 4 24 2005 4 29 2005) April 24-29 dd"
1460 "DTSTART;VALUE=DATE:20050424
1461 DTEND;VALUE=DATE:20050430
1462 SUMMARY:April 24-29 dd
1463 ")
1464 (icalendar-tests--test-export
1465 nil
1466 nil
1467 "%%(diary-block 5 30 2005 6 1 2005) may 30 - June 1: ee"
1468 "DTSTART;VALUE=DATE:20050530
1469 DTEND;VALUE=DATE:20050602
1470 SUMMARY:may 30 - June 1: ee")
1471
1472 (icalendar-tests--test-export
1473 nil
1474 nil
1475 "%%(diary-block 6 6 2005 6 8 2005) ff"
1476 "DTSTART;VALUE=DATE:20050606
1477 DTEND;VALUE=DATE:20050609
1478 SUMMARY:ff")
1479
1480 ;; export 2004-10-28 anniversary entries
1481 (icalendar-tests--test-export
1482 nil
1483 nil
1484 "
1485 >>> anniversaries:
1486
1487 %%(diary-anniversary 3 28 1991) aa birthday (%d years old)"
1488 "DTSTART;VALUE=DATE:19910328
1489 DTEND;VALUE=DATE:19910329
1490 RRULE:FREQ=YEARLY;INTERVAL=1;BYMONTH=03;BYMONTHDAY=28
1491 SUMMARY:aa birthday (%d years old)
1492 ")
1493
1494 (icalendar-tests--test-export
1495 nil
1496 nil
1497 "%%(diary-anniversary 5 17 1957) bb birthday (%d years old)"
1498 "DTSTART;VALUE=DATE:19570517
1499 DTEND;VALUE=DATE:19570518
1500 RRULE:FREQ=YEARLY;INTERVAL=1;BYMONTH=05;BYMONTHDAY=17
1501 SUMMARY:bb birthday (%d years old)")
1502
1503 (icalendar-tests--test-export
1504 nil
1505 nil
1506 "%%(diary-anniversary 6 8 1997) cc birthday (%d years old)"
1507 "DTSTART;VALUE=DATE:19970608
1508 DTEND;VALUE=DATE:19970609
1509 RRULE:FREQ=YEARLY;INTERVAL=1;BYMONTH=06;BYMONTHDAY=08
1510 SUMMARY:cc birthday (%d years old)")
1511
1512 (icalendar-tests--test-export
1513 nil
1514 nil
1515 "%%(diary-anniversary 7 22 1983) dd (%d years ago...!)"
1516 "DTSTART;VALUE=DATE:19830722
1517 DTEND;VALUE=DATE:19830723
1518 RRULE:FREQ=YEARLY;INTERVAL=1;BYMONTH=07;BYMONTHDAY=22
1519 SUMMARY:dd (%d years ago...!)")
1520
1521 (icalendar-tests--test-export
1522 nil
1523 nil
1524 "%%(diary-anniversary 8 1 1988) ee birthday (%d years old)"
1525 "DTSTART;VALUE=DATE:19880801
1526 DTEND;VALUE=DATE:19880802
1527 RRULE:FREQ=YEARLY;INTERVAL=1;BYMONTH=08;BYMONTHDAY=01
1528 SUMMARY:ee birthday (%d years old)")
1529
1530 (icalendar-tests--test-export
1531 nil
1532 nil
1533 "%%(diary-anniversary 9 21 1957) ff birthday (%d years old)"
1534 "DTSTART;VALUE=DATE:19570921
1535 DTEND;VALUE=DATE:19570922
1536 RRULE:FREQ=YEARLY;INTERVAL=1;BYMONTH=09;BYMONTHDAY=21
1537 SUMMARY:ff birthday (%d years old)")
1538
1539
1540 ;; FIXME!
1541
1542 ;; export 2004-10-28 monthly, weekly entries
1543
1544 ;; (icalendar-tests--test-export
1545 ;; nil
1546 ;; "
1547 ;; >>> ------------ monthly:
1548
1549 ;; */27/* 10:00 blah blah"
1550 ;; "xxx")
1551
1552 (icalendar-tests--test-export
1553 nil
1554 nil
1555 ">>> ------------ my week:
1556
1557 Monday 13:00 MAC"
1558 "DTSTART;VALUE=DATE-TIME:20000103T130000
1559 DTEND;VALUE=DATE-TIME:20000103T140000
1560 RRULE:FREQ=WEEKLY;INTERVAL=1;BYDAY=MO
1561 SUMMARY:MAC")
1562
1563 (icalendar-tests--test-export
1564 nil
1565 nil
1566 "Monday 15:00 a1"
1567 "DTSTART;VALUE=DATE-TIME:20000103T150000
1568 DTEND;VALUE=DATE-TIME:20000103T160000
1569 RRULE:FREQ=WEEKLY;INTERVAL=1;BYDAY=MO
1570 SUMMARY:a1")
1571
1572
1573 (icalendar-tests--test-export
1574 nil
1575 nil
1576 "Monday 16:00-17:00 a2"
1577 "DTSTART;VALUE=DATE-TIME:20000103T160000
1578 DTEND;VALUE=DATE-TIME:20000103T170000
1579 RRULE:FREQ=WEEKLY;INTERVAL=1;BYDAY=MO
1580 SUMMARY:a2")
1581
1582 (icalendar-tests--test-export
1583 nil
1584 nil
1585 "Tuesday 11:30-13:00 a3"
1586 "DTSTART;VALUE=DATE-TIME:20000104T113000
1587 DTEND;VALUE=DATE-TIME:20000104T130000
1588 RRULE:FREQ=WEEKLY;INTERVAL=1;BYDAY=TU
1589 SUMMARY:a3")
1590
1591 (icalendar-tests--test-export
1592 nil
1593 nil
1594 "Tuesday 15:00 a4"
1595 "DTSTART;VALUE=DATE-TIME:20000104T150000
1596 DTEND;VALUE=DATE-TIME:20000104T160000
1597 RRULE:FREQ=WEEKLY;INTERVAL=1;BYDAY=TU
1598 SUMMARY:a4")
1599
1600 (icalendar-tests--test-export
1601 nil
1602 nil
1603 "Wednesday 13:00 a5"
1604 "DTSTART;VALUE=DATE-TIME:20000105T130000
1605 DTEND;VALUE=DATE-TIME:20000105T140000
1606 RRULE:FREQ=WEEKLY;INTERVAL=1;BYDAY=WE
1607 SUMMARY:a5")
1608
1609 (icalendar-tests--test-export
1610 nil
1611 nil
1612 "Wednesday 11:30-13:30 a6"
1613 "DTSTART;VALUE=DATE-TIME:20000105T113000
1614 DTEND;VALUE=DATE-TIME:20000105T133000
1615 RRULE:FREQ=WEEKLY;INTERVAL=1;BYDAY=WE
1616 SUMMARY:a6")
1617
1618 (icalendar-tests--test-export
1619 nil
1620 nil
1621 "Wednesday 15:00 s1"
1622 "DTSTART;VALUE=DATE-TIME:20000105T150000
1623 DTEND;VALUE=DATE-TIME:20000105T160000
1624 RRULE:FREQ=WEEKLY;INTERVAL=1;BYDAY=WE
1625 SUMMARY:s1")
1626
1627
1628 ;; export 2004-10-28 regular entries
1629 (icalendar-tests--test-export
1630 nil
1631 nil
1632 "
1633 >>> regular diary entries:
1634
1635 Oct 12 2004, 14:00 Tue: [2004-10-12] q1"
1636 "DTSTART;VALUE=DATE-TIME:20041012T140000
1637 DTEND;VALUE=DATE-TIME:20041012T150000
1638 SUMMARY:Tue: [2004-10-12] q1")
1639
1640 ;; 2004-11-19
1641 (icalendar-tests--test-import
1642 "BEGIN:VCALENDAR
1643 VERSION
1644 :2.0
1645 PRODID
1646 :-//Mozilla.org/NONSGML Mozilla Calendar V1.0//EN
1647 BEGIN:VEVENT
1648 SUMMARY
1649 :Jjjjj & Wwwww
1650 STATUS
1651 :TENTATIVE
1652 CLASS
1653 :PRIVATE
1654 X-MOZILLA-ALARM-DEFAULT-LENGTH
1655 :0
1656 DTSTART
1657 :20041123T140000
1658 DTEND
1659 :20041123T143000
1660 DTSTAMP
1661 :20041118T013430Z
1662 LAST-MODIFIED
1663 :20041118T013640Z
1664 END:VEVENT
1665 BEGIN:VEVENT
1666 SUMMARY
1667 :BB Aaaaaaaa Bbbbb
1668 STATUS
1669 :TENTATIVE
1670 CLASS
1671 :PRIVATE
1672 X-MOZILLA-ALARM-DEFAULT-LENGTH
1673 :0
1674 DTSTART
1675 :20041123T144500
1676 DTEND
1677 :20041123T154500
1678 DTSTAMP
1679 :20041118T013641Z
1680 END:VEVENT
1681 BEGIN:VEVENT
1682 SUMMARY
1683 :Hhhhhhhh
1684 STATUS
1685 :TENTATIVE
1686 CLASS
1687 :PRIVATE
1688 X-MOZILLA-ALARM-DEFAULT-LENGTH
1689 :0
1690 DTSTART
1691 :20041123T110000
1692 DTEND
1693 :20041123T120000
1694 DTSTAMP
1695 :20041118T013831Z
1696 END:VEVENT
1697 BEGIN:VEVENT
1698 SUMMARY
1699 :MMM Aaaaaaaaa
1700 STATUS
1701 :TENTATIVE
1702 CLASS
1703 :PRIVATE
1704 X-MOZILLA-ALARM-DEFAULT-LENGTH
1705 :0
1706 X-MOZILLA-RECUR-DEFAULT-INTERVAL
1707 :2
1708 RRULE
1709 :FREQ=WEEKLY;INTERVAL=2;BYDAY=FR
1710 DTSTART
1711 :20041112T140000
1712 DTEND
1713 :20041112T183000
1714 DTSTAMP
1715 :20041118T014117Z
1716 END:VEVENT
1717 BEGIN:VEVENT
1718 SUMMARY
1719 :Rrrr/Cccccc ii Aaaaaaaa
1720 DESCRIPTION
1721 :Vvvvv Rrrr aaa Cccccc
1722 STATUS
1723 :TENTATIVE
1724 CLASS
1725 :PRIVATE
1726 X-MOZILLA-ALARM-DEFAULT-LENGTH
1727 :0
1728 DTSTART
1729 ;VALUE=DATE
1730 :20041119
1731 DTEND
1732 ;VALUE=DATE
1733 :20041120
1734 DTSTAMP
1735 :20041118T013107Z
1736 LAST-MODIFIED
1737 :20041118T014203Z
1738 END:VEVENT
1739 BEGIN:VEVENT
1740 SUMMARY
1741 :Wwww aa hhhh
1742 STATUS
1743 :TENTATIVE
1744 CLASS
1745 :PRIVATE
1746 X-MOZILLA-ALARM-DEFAULT-LENGTH
1747 :0
1748 RRULE
1749 :FREQ=WEEKLY;INTERVAL=1;BYDAY=MO
1750 DTSTART
1751 ;VALUE=DATE
1752 :20041101
1753 DTEND
1754 ;VALUE=DATE
1755 :20041102
1756 DTSTAMP
1757 :20041118T014045Z
1758 LAST-MODIFIED
1759 :20041118T023846Z
1760 END:VEVENT
1761 END:VCALENDAR
1762 "
1763 nil
1764 "&23/11/2004 14:00-14:30 Jjjjj & Wwwww
1765 Status: TENTATIVE
1766 Class: PRIVATE
1767 &23/11/2004 14:45-15:45 BB Aaaaaaaa Bbbbb
1768 Status: TENTATIVE
1769 Class: PRIVATE
1770 &23/11/2004 11:00-12:00 Hhhhhhhh
1771 Status: TENTATIVE
1772 Class: PRIVATE
1773 &%%(and (diary-cyclic 14 12 11 2004)) 14:00-18:30 MMM Aaaaaaaaa
1774 Status: TENTATIVE
1775 Class: PRIVATE
1776 &%%(and (diary-block 19 11 2004 19 11 2004)) Rrrr/Cccccc ii Aaaaaaaa
1777 Desc: Vvvvv Rrrr aaa Cccccc
1778 Status: TENTATIVE
1779 Class: PRIVATE
1780 &%%(and (diary-cyclic 7 1 11 2004)) Wwww aa hhhh
1781 Status: TENTATIVE
1782 Class: PRIVATE
1783 "
1784 "&11/23/2004 14:00-14:30 Jjjjj & Wwwww
1785 Status: TENTATIVE
1786 Class: PRIVATE
1787 &11/23/2004 14:45-15:45 BB Aaaaaaaa Bbbbb
1788 Status: TENTATIVE
1789 Class: PRIVATE
1790 &11/23/2004 11:00-12:00 Hhhhhhhh
1791 Status: TENTATIVE
1792 Class: PRIVATE
1793 &%%(and (diary-cyclic 14 11 12 2004)) 14:00-18:30 MMM Aaaaaaaaa
1794 Status: TENTATIVE
1795 Class: PRIVATE
1796 &%%(and (diary-block 11 19 2004 11 19 2004)) Rrrr/Cccccc ii Aaaaaaaa
1797 Desc: Vvvvv Rrrr aaa Cccccc
1798 Status: TENTATIVE
1799 Class: PRIVATE
1800 &%%(and (diary-cyclic 7 11 1 2004)) Wwww aa hhhh
1801 Status: TENTATIVE
1802 Class: PRIVATE
1803 ")
1804
1805 ;; 2004-09-09 pg
1806 (icalendar-tests--test-export
1807 "%%(diary-block 1 1 2004 4 1 2004) Urlaub"
1808 nil
1809 nil
1810 "DTSTART;VALUE=DATE:20040101
1811 DTEND;VALUE=DATE:20040105
1812 SUMMARY:Urlaub")
1813
1814 ;; 2004-10-25 pg
1815 (icalendar-tests--test-export
1816 nil
1817 "5 11 2004 Bla Fasel"
1818 nil
1819 "DTSTART;VALUE=DATE:20041105
1820 DTEND;VALUE=DATE:20041106
1821 SUMMARY:Bla Fasel")
1822
1823 ;; 2004-10-30 pg
1824 (icalendar-tests--test-export
1825 nil
1826 "2 Nov 2004 15:00-16:30 Zahnarzt"
1827 nil
1828 "DTSTART;VALUE=DATE-TIME:20041102T150000
1829 DTEND;VALUE=DATE-TIME:20041102T163000
1830 SUMMARY:Zahnarzt")
1831
1832 ;; 2005-02-07 lt
1833 (icalendar-tests--test-import
1834 "UID
1835 :b60d398e-1dd1-11b2-a159-cf8cb05139f4
1836 SUMMARY
1837 :Waitangi Day
1838 DESCRIPTION
1839 :abcdef
1840 CATEGORIES
1841 :Public Holiday
1842 STATUS
1843 :CONFIRMED
1844 CLASS
1845 :PRIVATE
1846 DTSTART
1847 ;VALUE=DATE
1848 :20050206
1849 DTEND
1850 ;VALUE=DATE
1851 :20050207
1852 DTSTAMP
1853 :20050128T011209Z"
1854 nil
1855 "&%%(and (diary-block 6 2 2005 6 2 2005)) Waitangi Day
1856 Desc: abcdef
1857 Status: CONFIRMED
1858 Class: PRIVATE
1859 UID: b60d398e-1dd1-11b2-a159-cf8cb05139f4
1860 "
1861 "&%%(and (diary-block 2 6 2005 2 6 2005)) Waitangi Day
1862 Desc: abcdef
1863 Status: CONFIRMED
1864 Class: PRIVATE
1865 UID: b60d398e-1dd1-11b2-a159-cf8cb05139f4
1866 ")
1867
1868 ;; 2005-03-01 lt
1869 (icalendar-tests--test-import
1870 "DTSTART;VALUE=DATE:20050217
1871 SUMMARY:Hhhhhh Aaaaa ii Aaaaaaaa
1872 UID:6AFA7558-6994-11D9-8A3A-000A95A0E830-RID
1873 DTSTAMP:20050118T210335Z
1874 DURATION:P7D"
1875 nil
1876 "&%%(and (diary-block 17 2 2005 23 2 2005)) Hhhhhh Aaaaa ii Aaaaaaaa
1877 UID: 6AFA7558-6994-11D9-8A3A-000A95A0E830-RID\n"
1878 "&%%(and (diary-block 2 17 2005 2 23 2005)) Hhhhhh Aaaaa ii Aaaaaaaa
1879 UID: 6AFA7558-6994-11D9-8A3A-000A95A0E830-RID\n")
1880
1881 ;; 2005-03-23 lt
1882 (icalendar-tests--test-export
1883 nil
1884 "&%%(diary-cyclic 7 8 2 2005) 16:00-16:45 [WORK] Pppp"
1885 nil
1886 "DTSTART;VALUE=DATE-TIME:20050208T160000
1887 DTEND;VALUE=DATE-TIME:20050208T164500
1888 RRULE:FREQ=DAILY;INTERVAL=7
1889 SUMMARY:[WORK] Pppp
1890 ")
1891
1892 ;; 2005-05-27 eu
1893 (icalendar-tests--test-export
1894 nil
1895 nil
1896 ;; FIXME: colon not allowed!
1897 ;;"Nov 1: NNN Wwwwwwww Wwwww - Aaaaaa Pppppppp rrrrrr ddd oo Nnnnnnnn 30"
1898 "Nov 1 NNN Wwwwwwww Wwwww - Aaaaaa Pppppppp rrrrrr ddd oo Nnnnnnnn 30"
1899 "DTSTART;VALUE=DATE:19001101
1900 DTEND;VALUE=DATE:19001102
1901 RRULE:FREQ=YEARLY;INTERVAL=1;BYMONTH=11;BYMONTHDAY=1
1902 SUMMARY:NNN Wwwwwwww Wwwww - Aaaaaa Pppppppp rrrrrr ddd oo Nnnnnnnn 30
1903 ")
1904
1905 ;; bug#11473
1906 (icalendar-tests--test-import
1907 "BEGIN:VCALENDAR
1908 METHOD:REQUEST
1909 PRODID:Microsoft Exchange Server 2007
1910 VERSION:2.0
1911 BEGIN:VTIMEZONE
1912 TZID:(UTC+01:00) Amsterdam\, Berlin\, Bern\, Rome\, Stockholm\, Vienna
1913 BEGIN:STANDARD
1914 DTSTART:16010101T030000
1915 TZOFFSETFROM:+0200
1916 TZOFFSETTO:+0100
1917 RRULE:FREQ=YEARLY;INTERVAL=1;BYDAY=-1SU;BYMONTH=10
1918 END:STANDARD
1919 BEGIN:DAYLIGHT
1920 DTSTART:16010101T020000
1921 TZOFFSETFROM:+0100
1922 TZOFFSETTO:+0200
1923 RRULE:FREQ=YEARLY;INTERVAL=1;BYDAY=-1SU;BYMONTH=3
1924 END:DAYLIGHT
1925 END:VTIMEZONE
1926 BEGIN:VEVENT
1927 ORGANIZER;CN=\"A. Luser\":MAILTO:a.luser@foo.com
1928 ATTENDEE;ROLE=REQ-PARTICIPANT;PARTSTAT=NEEDS-ACTION;RSVP=TRUE;CN=\"Luser, Oth
1929 er\":MAILTO:other.luser@foo.com
1930 DESCRIPTION;LANGUAGE=en-US:\nWhassup?\n\n
1931 SUMMARY;LANGUAGE=en-US:Query
1932 DTSTART;TZID=\"(UTC+01:00) Amsterdam, Berlin, Bern, Rome, Stockholm, Vienna\"
1933 :20120515T150000
1934 DTEND;TZID=\"(UTC+01:00) Amsterdam, Berlin, Bern, Rome, Stockholm, Vienna\":2
1935 0120515T153000
1936 UID:040000008200E00074C5B7101A82E0080000000020FFAED0CFEFCC01000000000000000
1937 010000000575268034ECDB649A15349B1BF240F15
1938 RECURRENCE-ID;TZID=\"(UTC+01:00) Amsterdam, Berlin, Bern, Rome, Stockholm, V
1939 ienna\":20120515T170000
1940 CLASS:PUBLIC
1941 PRIORITY:5
1942 DTSTAMP:20120514T153645Z
1943 TRANSP:OPAQUE
1944 STATUS:CONFIRMED
1945 SEQUENCE:15
1946 LOCATION;LANGUAGE=en-US:phone
1947 X-MICROSOFT-CDO-APPT-SEQUENCE:15
1948 X-MICROSOFT-CDO-OWNERAPPTID:1907632092
1949 X-MICROSOFT-CDO-BUSYSTATUS:TENTATIVE
1950 X-MICROSOFT-CDO-INTENDEDSTATUS:BUSY
1951 X-MICROSOFT-CDO-ALLDAYEVENT:FALSE
1952 X-MICROSOFT-CDO-IMPORTANCE:1
1953 X-MICROSOFT-CDO-INSTTYPE:3
1954 BEGIN:VALARM
1955 ACTION:DISPLAY
1956 DESCRIPTION:REMINDER
1957 TRIGGER;RELATED=START:-PT15M
1958 END:VALARM
1959 END:VEVENT
1960 END:VCALENDAR"
1961 nil
1962 "&15/5/2012 15:00-15:30 Query
1963 Location: phone
1964 Organizer: MAILTO:a.luser@foo.com
1965 Status: CONFIRMED
1966 Class: PUBLIC
1967 UID: 040000008200E00074C5B7101A82E0080000000020FFAED0CFEFCC01000000000000000010000000575268034ECDB649A15349B1BF240F15
1968 " nil)
1969 )
1970
1971 (provide 'icalendar-tests)
1972 ;;; icalendar-tests.el ends here