aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorUlf Jasper2009-12-18 19:35:14 +0000
committerUlf Jasper2009-12-18 19:35:14 +0000
commit6fe539d246f75dbba74b95a5ace37ea8ce91e3dd (patch)
tree1d20a43661890f4c771748b88e7e47bcb4f5f5a8
parent83828b06e39f2d3586fbca04b4f3335a442a2f9b (diff)
downloademacs-6fe539d246f75dbba74b95a5ace37ea8ce91e3dd.tar.gz
emacs-6fe539d246f75dbba74b95a5ace37ea8ce91e3dd.zip
Fixed timezone handling problem in icalendar.el.
-rw-r--r--lisp/ChangeLog8
-rw-r--r--lisp/calendar/icalendar.el12
-rw-r--r--test/ChangeLog12
-rw-r--r--test/icalendar-testsuite.el90
4 files changed, 101 insertions, 21 deletions
diff --git a/lisp/ChangeLog b/lisp/ChangeLog
index f3cff6c8137..193aa942fe1 100644
--- a/lisp/ChangeLog
+++ b/lisp/ChangeLog
@@ -1,3 +1,11 @@
12009-12-18 Ulf Jasper <ulf.jasper@web.de>
2
3 * calendar/icalendar.el (icalendar--convert-tz-offset): Fixed
4 timezone names.
5 (icalendar--convert-tz-offset): Fixed the "last-day-problem".
6 (icalendar--add-diary-entry): Remove the trailing blank that
7 diary-make-entry inserts.
8
12009-12-17 Michael Albinus <michael.albinus@gmx.de> 92009-12-17 Michael Albinus <michael.albinus@gmx.de>
2 10
3 Make `file-expand-wildcards' work for remote files. 11 Make `file-expand-wildcards' work for remote files.
diff --git a/lisp/calendar/icalendar.el b/lisp/calendar/icalendar.el
index 0bf4c08a122..2dade482858 100644
--- a/lisp/calendar/icalendar.el
+++ b/lisp/calendar/icalendar.el
@@ -454,7 +454,7 @@ The strings are suitable for assembling into a TZ variable."
454 (cons 454 (cons
455 (concat 455 (concat
456 ;; Fake a name. 456 ;; Fake a name.
457 (if dst-p "(DST?)" "(STD?)") 457 (if dst-p "DST" "STD")
458 ;; For TZ, OFFSET is added to the local time. So, 458 ;; For TZ, OFFSET is added to the local time. So,
459 ;; invert the values. 459 ;; invert the values.
460 (if (eq (aref offset 0) ?-) "+" "-") 460 (if (eq (aref offset 0) ?-) "+" "-")
@@ -466,6 +466,10 @@ The strings are suitable for assembling into a TZ variable."
466 (week (if (eq day -1) 466 (week (if (eq day -1)
467 byday 467 byday
468 (substring byday 0 -2)))) 468 (substring byday 0 -2))))
469 ;; "Translate" the icalendar way to specify the last
470 ;; (sun|mon|...)day in month to the tzset way.
471 (if (string= week "-1") ; last day as icalendar calls it
472 (setq week "5")) ; last day as tzset calls it
469 (concat "M" bymonth "." week "." (if (eq day -1) "0" 473 (concat "M" bymonth "." week "." (if (eq day -1) "0"
470 (int-to-string day)) 474 (int-to-string day))
471 ;; Start time. 475 ;; Start time.
@@ -2241,6 +2245,12 @@ the entry."
2241 'diary-make-entry 2245 'diary-make-entry
2242 'make-diary-entry) 2246 'make-diary-entry)
2243 string non-marking diary-file))) 2247 string non-marking diary-file)))
2248 ;; Würgaround to remove the trailing blank char
2249 (save-excursion
2250 (set-buffer (find-file diary-file))
2251 (goto-char (point-max))
2252 (if (= (char-before) ? )
2253 (delete-char -1)))
2244 ;; return diary-file in case it has been changed interactively 2254 ;; return diary-file in case it has been changed interactively
2245 diary-file) 2255 diary-file)
2246 2256
diff --git a/test/ChangeLog b/test/ChangeLog
index a5dc9b86e79..4eefb50b95b 100644
--- a/test/ChangeLog
+++ b/test/ChangeLog
@@ -1,3 +1,15 @@
12009-12-18 Ulf Jasper <ulf.jasper@web.de>
2
3 * icalendar-testsuite.el
4 (icalendar-testsuite--run-function-tests): Added
5 icalendar-testsuite--test-parse-vtimezone.
6 (icalendar-testsuite--test-parse-vtimezone): New.
7 (icalendar-testsuite--do-test-cycle): Doc changes.
8 (icalendar-testsuite--run-real-world-tests): Removed trailing
9 whitespace -- see change of icalendar--add-diary-entry in
10 icalendar.el.
11 (icalendar-testsuite--run-cycle-tests): Re-enabled all tests.
12
12009-09-30 Glenn Morris <rgm@gnu.org> 132009-09-30 Glenn Morris <rgm@gnu.org>
2 14
3 * cedet/semantic-utest-c.el: Relicense under GPLv3+. 15 * cedet/semantic-utest-c.el: Relicense under GPLv3+.
diff --git a/test/icalendar-testsuite.el b/test/icalendar-testsuite.el
index e926eabce24..fa361c26da0 100644
--- a/test/icalendar-testsuite.el
+++ b/test/icalendar-testsuite.el
@@ -53,7 +53,8 @@
53 (icalendar-testsuite--test-datetime-to-diary-date) 53 (icalendar-testsuite--test-datetime-to-diary-date)
54 (icalendar-testsuite--test-diarytime-to-isotime) 54 (icalendar-testsuite--test-diarytime-to-isotime)
55 (icalendar-testsuite--test-calendar-style) 55 (icalendar-testsuite--test-calendar-style)
56 (icalendar-testsuite--test-create-uid)) 56 (icalendar-testsuite--test-create-uid)
57 (icalendar-testsuite--test-parse-vtimezone))
57 58
58(defun icalendar-testsuite--test-format-ical-event () 59(defun icalendar-testsuite--test-format-ical-event ()
59 "Test `icalendar--format-ical-event'." 60 "Test `icalendar--format-ical-event'."
@@ -272,6 +273,48 @@ END:VEVENT
272 (icalendar--create-uid entry-full contents))) 273 (icalendar--create-uid entry-full contents)))
273 )) 274 ))
274 275
276(defun icalendar-testsuite--test-parse-vtimezone ()
277 (let (vtimezone result)
278 (setq vtimezone (icalendar-testsuite--get-ical-event "BEGIN:VTIMEZONE
279TZID:thename
280BEGIN:STANDARD
281DTSTART:16010101T040000
282TZOFFSETFROM:+0300
283TZOFFSETTO:+0200
284RRULE:FREQ=YEARLY;INTERVAL=1;BYDAY=-1SU;BYMONTH=10
285END:STANDARD
286BEGIN:DAYLIGHT
287DTSTART:16010101T030000
288TZOFFSETFROM:+0200
289TZOFFSETTO:+0300
290RRULE:FREQ=YEARLY;INTERVAL=1;BYDAY=-1SU;BYMONTH=3
291END:DAYLIGHT
292END:VTIMEZONE
293"))
294 (setq result (icalendar--parse-vtimezone vtimezone))
295 (assert (string= "thename" (car result)))
296 (message (cdr result))
297 (assert (string= "STD-02:00DST-03:00,M3.5.0/03:00:00,M10.5.0/04:00:00" (cdr result)))
298 (setq vtimezone (icalendar-testsuite--get-ical-event "BEGIN:VTIMEZONE
299TZID:anothername
300BEGIN:STANDARD
301DTSTART:16010101T040000
302TZOFFSETFROM:+0300
303TZOFFSETTO:+0200
304RRULE:FREQ=YEARLY;INTERVAL=1;BYDAY=2MO;BYMONTH=10
305END:STANDARD
306BEGIN:DAYLIGHT
307DTSTART:16010101T030000
308TZOFFSETFROM:+0200
309TZOFFSETTO:+0300
310RRULE:FREQ=YEARLY;INTERVAL=1;BYDAY=2MO;BYMONTH=3
311END:DAYLIGHT
312END:VTIMEZONE
313"))
314 (setq result (icalendar--parse-vtimezone vtimezone))
315 (assert (string= "anothername" (car result)))
316 (message (cdr result))
317 (assert (string= "STD-02:00DST-03:00,M3.2.1/03:00:00,M10.2.1/04:00:00" (cdr result)))))
275 318
276;; ====================================================================== 319;; ======================================================================
277;; Test methods for exporting from diary to icalendar 320;; Test methods for exporting from diary to icalendar
@@ -455,10 +498,16 @@ Argument INPUT icalendar event string."
455 (let ((temp-diary (make-temp-file "icalendar-test-diary")) 498 (let ((temp-diary (make-temp-file "icalendar-test-diary"))
456 (temp-ics (make-temp-file "icalendar-test-ics")) 499 (temp-ics (make-temp-file "icalendar-test-ics"))
457 (org-input (buffer-substring-no-properties (point-min) (point-max)))) 500 (org-input (buffer-substring-no-properties (point-min) (point-max))))
501
502 ;; step 1: import
458 (icalendar-import-buffer temp-diary t t) 503 (icalendar-import-buffer temp-diary t t)
504
505 ;; step 2: export what was just imported
459 (save-excursion 506 (save-excursion
460 (find-file temp-diary) 507 (find-file temp-diary)
461 (icalendar-export-region (point-min) (point-max) temp-ics)) 508 (icalendar-export-region (point-min) (point-max) temp-ics))
509
510 ;; compare the output of step 2 with the input of step 1
462 (save-excursion 511 (save-excursion
463 (find-file temp-ics) 512 (find-file temp-ics)
464 (goto-char (point-min)) 513 (goto-char (point-min))
@@ -468,6 +517,8 @@ Argument INPUT icalendar event string."
468 (unless (string-equal org-input cycled) 517 (unless (string-equal org-input cycled)
469 (error "Import test failed! Found `%s'\nbut expected `%s'" cycled 518 (error "Import test failed! Found `%s'\nbut expected `%s'" cycled
470 org-input)))) 519 org-input))))
520
521 ;; clean up -- Note this is done only if test is passed
471 (kill-buffer (find-buffer-visiting temp-diary)) 522 (kill-buffer (find-buffer-visiting temp-diary))
472 (save-excursion 523 (save-excursion
473 (set-buffer (find-buffer-visiting temp-ics)) 524 (set-buffer (find-buffer-visiting temp-ics))
@@ -1410,42 +1461,42 @@ END:VCALENDAR
1410 nil 1461 nil
1411 "&23/11/2004 14:00-14:30 Jjjjj & Wwwww 1462 "&23/11/2004 14:00-14:30 Jjjjj & Wwwww
1412 Status: TENTATIVE 1463 Status: TENTATIVE
1413 Class: PRIVATE 1464 Class: PRIVATE
1414&23/11/2004 14:45-15:45 BB Aaaaaaaa Bbbbb 1465&23/11/2004 14:45-15:45 BB Aaaaaaaa Bbbbb
1415 Status: TENTATIVE 1466 Status: TENTATIVE
1416 Class: PRIVATE 1467 Class: PRIVATE
1417&23/11/2004 11:00-12:00 Hhhhhhhh 1468&23/11/2004 11:00-12:00 Hhhhhhhh
1418 Status: TENTATIVE 1469 Status: TENTATIVE
1419 Class: PRIVATE 1470 Class: PRIVATE
1420&%%(and (diary-cyclic 14 12 11 2004)) 14:00-18:30 MMM Aaaaaaaaa 1471&%%(and (diary-cyclic 14 12 11 2004)) 14:00-18:30 MMM Aaaaaaaaa
1421 Status: TENTATIVE 1472 Status: TENTATIVE
1422 Class: PRIVATE 1473 Class: PRIVATE
1423&%%(and (diary-block 19 11 2004 19 11 2004)) Rrrr/Cccccc ii Aaaaaaaa 1474&%%(and (diary-block 19 11 2004 19 11 2004)) Rrrr/Cccccc ii Aaaaaaaa
1424 Desc: Vvvvv Rrrr aaa Cccccc 1475 Desc: Vvvvv Rrrr aaa Cccccc
1425 Status: TENTATIVE 1476 Status: TENTATIVE
1426 Class: PRIVATE 1477 Class: PRIVATE
1427&%%(and (diary-cyclic 7 1 11 2004)) Wwww aa hhhh 1478&%%(and (diary-cyclic 7 1 11 2004)) Wwww aa hhhh
1428 Status: TENTATIVE 1479 Status: TENTATIVE
1429 Class: PRIVATE " 1480 Class: PRIVATE"
1430 "&11/23/2004 14:00-14:30 Jjjjj & Wwwww 1481 "&11/23/2004 14:00-14:30 Jjjjj & Wwwww
1431 Status: TENTATIVE 1482 Status: TENTATIVE
1432 Class: PRIVATE 1483 Class: PRIVATE
1433&11/23/2004 14:45-15:45 BB Aaaaaaaa Bbbbb 1484&11/23/2004 14:45-15:45 BB Aaaaaaaa Bbbbb
1434 Status: TENTATIVE 1485 Status: TENTATIVE
1435 Class: PRIVATE 1486 Class: PRIVATE
1436&11/23/2004 11:00-12:00 Hhhhhhhh 1487&11/23/2004 11:00-12:00 Hhhhhhhh
1437 Status: TENTATIVE 1488 Status: TENTATIVE
1438 Class: PRIVATE 1489 Class: PRIVATE
1439&%%(and (diary-cyclic 14 11 12 2004)) 14:00-18:30 MMM Aaaaaaaaa 1490&%%(and (diary-cyclic 14 11 12 2004)) 14:00-18:30 MMM Aaaaaaaaa
1440 Status: TENTATIVE 1491 Status: TENTATIVE
1441 Class: PRIVATE 1492 Class: PRIVATE
1442&%%(and (diary-block 11 19 2004 11 19 2004)) Rrrr/Cccccc ii Aaaaaaaa 1493&%%(and (diary-block 11 19 2004 11 19 2004)) Rrrr/Cccccc ii Aaaaaaaa
1443 Desc: Vvvvv Rrrr aaa Cccccc 1494 Desc: Vvvvv Rrrr aaa Cccccc
1444 Status: TENTATIVE 1495 Status: TENTATIVE
1445 Class: PRIVATE 1496 Class: PRIVATE
1446&%%(and (diary-cyclic 7 11 1 2004)) Wwww aa hhhh 1497&%%(and (diary-cyclic 7 11 1 2004)) Wwww aa hhhh
1447 Status: TENTATIVE 1498 Status: TENTATIVE
1448 Class: PRIVATE ") 1499 Class: PRIVATE")
1449 1500
1450 ;; 2004-09-09 pg 1501 ;; 2004-09-09 pg
1451 (icalendar-testsuite--test-export 1502 (icalendar-testsuite--test-export
@@ -1555,13 +1606,12 @@ LOCATION:nowhere
1555ORGANIZER:ulf 1606ORGANIZER:ulf
1556") 1607")
1557 1608
1558 ;; FIXME: does not work 1609 (icalendar-testsuite--test-cycle
1559 ;; (icalendar-testsuite--test-cycle 1610 "DTSTART;VALUE=DATE:19190909
1560 ;; "DTSTART;VALUE=DATE:19190909 1611DTEND;VALUE=DATE:19190910
1561 ;;DTEND;VALUE=DATE:19190910 1612RRULE:FREQ=YEARLY;INTERVAL=1;BYMONTH=09;BYMONTHDAY=09
1562 ;;RRULE:FREQ=YEARLY;INTERVAL=1;BYMONTH=09;BYMONTHDAY=09 1613SUMMARY:and diary-anniversary
1563 ;;SUMMARY:and diary-anniversary 1614")
1564 ;;")
1565 ) 1615 )
1566 1616
1567 1617