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