Mercurial > emacs
changeset 107199:8ce4f8460ed4
Fixed bug#5549 (icalendar.el)
author | Ulf Jasper <ulf.jasper@web.de> |
---|---|
date | Fri, 19 Feb 2010 19:59:00 +0100 |
parents | f32d789c9aab |
children | e8c35d7a4eac |
files | lisp/ChangeLog lisp/calendar/icalendar.el test/ChangeLog test/icalendar-testsuite.el |
diffstat | 4 files changed, 150 insertions(+), 15 deletions(-) [+] |
line wrap: on
line diff
--- a/lisp/ChangeLog Fri Feb 19 15:57:53 2010 +0200 +++ b/lisp/ChangeLog Fri Feb 19 19:59:00 2010 +0100 @@ -1,3 +1,13 @@ +2010-02-19 Ulf Jasper <ulf.jasper@web.de> + + * calendar/icalendar.el (icalendar--convert-ordinary-to-ical) + (icalendar--convert-weekly-to-ical) + (icalendar--convert-yearly-to-ical) + (icalendar--convert-block-to-ical) + (icalendar--convert-cyclic-to-ical) + (icalendar--convert-anniversary-to-ical): Take care of time + specifications where hour has 1-digit only (Bug#5549). + 2010-02-19 Nick Roberts <nickrob@snap.net.nz> * progmodes/gdb-ui.el (gdb-assembler-handler): Accommodate change
--- a/lisp/calendar/icalendar.el Fri Feb 19 15:57:53 2010 +0200 +++ b/lisp/calendar/icalendar.el Fri Feb 19 19:59:00 2010 +0100 @@ -1175,9 +1175,9 @@ (if (string-match (concat nonmarker "\\([^ /]+[ /]+[^ /]+[ /]+[^ ]+\\)\\s-*" ; date - "\\(0?\\([1-9][0-9]?:[0-9][0-9]\\)\\([ap]m\\)?" ; start time + "\\(\\([0-9][0-9]?:[0-9][0-9]\\)\\([ap]m\\)?" ; start time "\\(" - "-0?\\([1-9][0-9]?:[0-9][0-9]\\)\\([ap]m\\)?\\)?" ; end time + "-\\([0-9][0-9]?:[0-9][0-9]\\)\\([ap]m\\)?\\)?" ; end time "\\)?" "\\s-*\\(.*?\\) ?$") entry-main) @@ -1271,10 +1271,10 @@ entries. ENTRY-MAIN is the first line of the diary entry." (if (and (string-match (concat nonmarker "\\([a-z]+\\)\\s-+" - "\\(0?\\([1-9][0-9]?:[0-9][0-9]\\)" + "\\(\\([0-9][0-9]?:[0-9][0-9]\\)" "\\([ap]m\\)?" - "\\(-0?" - "\\([1-9][0-9]?:[0-9][0-9]\\)" + "\\(-" + "\\([0-9][0-9]?:[0-9][0-9]\\)" "\\([ap]m\\)?\\)?" "\\)?" "\\s-*\\(.*?\\) ?$") @@ -1353,12 +1353,12 @@ entries. ENTRY-MAIN is the first line of the diary entry." (if (string-match (concat nonmarker (if (eq (icalendar--date-style) 'european) - "0?\\([1-9]+[0-9]?\\)\\s-+\\([a-z]+\\)\\s-+" - "\\([a-z]+\\)\\s-+0?\\([1-9]+[0-9]?\\)\\s-+") + "\\([0-9]+[0-9]?\\)\\s-+\\([a-z]+\\)\\s-+" + "\\([a-z]+\\)\\s-+\\([0-9]+[0-9]?\\)\\s-+") "\\*?\\s-*" - "\\(0?\\([1-9][0-9]?:[0-9][0-9]\\)\\([ap]m\\)?" + "\\(\\([0-9][0-9]?:[0-9][0-9]\\)\\([ap]m\\)?" "\\(" - "-0?\\([1-9][0-9]?:[0-9][0-9]\\)\\([ap]m\\)?\\)?" + "-\\([0-9][0-9]?:[0-9][0-9]\\)\\([ap]m\\)?\\)?" "\\)?" "\\s-*\\([^0-9]+.*?\\) ?$" ; must not match years ) @@ -1461,9 +1461,9 @@ (if (string-match (concat nonmarker "%%(diary-block \\([^ /]+[ /]+[^ /]+[ /]+[^ ]+\\)" " +\\([^ /]+[ /]+[^ /]+[ /]+[^ ]+\\))\\s-*" - "\\(0?\\([1-9][0-9]?:[0-9][0-9]\\)\\([ap]m\\)?" + "\\(\\([0-9][0-9]?:[0-9][0-9]\\)\\([ap]m\\)?" "\\(" - "-0?\\([1-9][0-9]?:[0-9][0-9]\\)\\([ap]m\\)?\\)?" + "-\\([0-9][0-9]?:[0-9][0-9]\\)\\([ap]m\\)?\\)?" "\\)?" "\\s-*\\(.*?\\) ?$") entry-main) @@ -1569,9 +1569,9 @@ (if (string-match (concat nonmarker "%%(diary-cyclic \\([^ ]+\\) +" "\\([^ /]+[ /]+[^ /]+[ /]+[^ ]+\\))\\s-*" - "\\(0?\\([1-9][0-9]?:[0-9][0-9]\\)\\([ap]m\\)?" + "\\(\\([0-9][0-9]?:[0-9][0-9]\\)\\([ap]m\\)?" "\\(" - "-0?\\([1-9][0-9]?:[0-9][0-9]\\)\\([ap]m\\)?\\)?" + "-\\([0-9][0-9]?:[0-9][0-9]\\)\\([ap]m\\)?\\)?" "\\)?" "\\s-*\\(.*?\\) ?$") entry-main) @@ -1642,9 +1642,9 @@ entries. ENTRY-MAIN is the first line of the diary entry." (if (string-match (concat nonmarker "%%(diary-anniversary \\([^)]+\\))\\s-*" - "\\(0?\\([1-9][0-9]?:[0-9][0-9]\\)\\([ap]m\\)?" + "\\(\\([0-9][0-9]?:[0-9][0-9]\\)\\([ap]m\\)?" "\\(" - "-0?\\([1-9][0-9]?:[0-9][0-9]\\)\\([ap]m\\)?\\)?" + "-\\([0-9][0-9]?:[0-9][0-9]\\)\\([ap]m\\)?\\)?" "\\)?" "\\s-*\\(.*?\\) ?$") entry-main)
--- a/test/ChangeLog Fri Feb 19 15:57:53 2010 +0200 +++ b/test/ChangeLog Fri Feb 19 19:59:00 2010 +0100 @@ -1,3 +1,16 @@ +2010-02-19 Ulf Jasper <ulf.jasper@web.de> + + * icalendar-testsuite.el + (icalendar-testsuite--run-function-tests): Added new tests. + (icalendar-testsuite--test-diarytime-to-isotime): Added another + testcase. + (icalendar-testsuite--test-convert-ordinary-to-ical): New. + (icalendar-testsuite--test-convert-weekly-to-ical): New. + (icalendar-testsuite--test-convert-yearly-to-ical): New. + (icalendar-testsuite--test-convert-block-to-ical): New. + (icalendar-testsuite--test-convert-cyclic-to-ical): New. + (icalendar-testsuite--test-convert-anniversary-to-ical): New. + 2010-01-18 Juanma Barranquero <lekktu@gmail.com> * cedet/semantic-tests.el (semanticdb-test-gnu-global)
--- a/test/icalendar-testsuite.el Fri Feb 19 15:57:53 2010 +0200 +++ b/test/icalendar-testsuite.el Fri Feb 19 19:59:00 2010 +0100 @@ -52,6 +52,12 @@ (icalendar-testsuite--test-datestring-to-isodate) (icalendar-testsuite--test-datetime-to-diary-date) (icalendar-testsuite--test-diarytime-to-isotime) + (icalendar-testsuite--test-convert-ordinary-to-ical) + (icalendar-testsuite--test-convert-weekly-to-ical) + (icalendar-testsuite--test-convert-yearly-to-ical) + (icalendar-testsuite--test-convert-block-to-ical) + (icalendar-testsuite--test-convert-cyclic-to-ical) + (icalendar-testsuite--test-convert-anniversary-to-ical) (icalendar-testsuite--test-calendar-style) (icalendar-testsuite--test-create-uid) (icalendar-testsuite--test-parse-vtimezone)) @@ -213,6 +219,12 @@ (defun icalendar-testsuite--test-diarytime-to-isotime () "Test method for `icalendar--diarytime-to-isotime'." + (assert (string= (icalendar--diarytime-to-isotime "01:15" "") + "T011500")) + (assert (string= (icalendar--diarytime-to-isotime "1:15" "") + "T011500")) + (assert (string= (icalendar--diarytime-to-isotime "0:01" "") + "T000100")) (assert (string= (icalendar--diarytime-to-isotime "0100" "") "T010000")) (assert (string= (icalendar--diarytime-to-isotime "0100" "am") @@ -236,6 +248,106 @@ (assert (string= (icalendar--diarytime-to-isotime "1259" "pm") "T125900"))) +(defun icalendar-testsuite--test-convert-ordinary-to-ical () + "Test method for `icalendar--convert-ordinary-to-ical'." + (let* ((calendar-date-style 'iso) + result) + ;; without time + (setq result (icalendar--convert-ordinary-to-ical "&?" "2010 2 15 subject")) + (assert (= 2 (length result))) + (assert (string= "\nDTSTART;VALUE=DATE:20100215\nDTEND;VALUE=DATE:20100216" + (car result))) + (assert (string= "subject" (cadr result))) + + ;; with time + (setq result (icalendar--convert-ordinary-to-ical + "&?" "&2010 2 15 12:34-23:45 s")) + (assert (= 2 (length result))) + (assert (string= (concat "\nDTSTART;VALUE=DATE-TIME:20100215T123400" + "\nDTEND;VALUE=DATE-TIME:20100215T234500") + (car result))) + (assert (string= "s" (cadr result))) + + ;; with time, again -- test bug#5549 + (setq result (icalendar--convert-ordinary-to-ical + "x?" "x2010 2 15 0:34-1:45 s")) + (assert (= 2 (length result))) + (assert (string= (concat "\nDTSTART;VALUE=DATE-TIME:20100215T003400" + "\nDTEND;VALUE=DATE-TIME:20100215T014500") + (car result))) + (assert (string= "s" (cadr result))))) + +(defun icalendar-testsuite--test-convert-weekly-to-ical () + "Test method for `icalendar--convert-weekly-to-ical'." + (let* ((calendar-date-style 'iso) + result + (calendar-day-name-array + ["Sunday" "Monday" "Tuesday" "Wednesday" "Thursday" "Friday" + "Saturday"])) + (setq result (icalendar--convert-weekly-to-ical "" "Monday 8:30 subject")) + (assert (= 2 (length result))) + (assert (string= (concat "\nDTSTART;VALUE=DATE-TIME:20050103T083000" + "\nDTEND;VALUE=DATE-TIME:20050103T093000" + "\nRRULE:FREQ=WEEKLY;INTERVAL=1;BYDAY=MO") + (car result))) + (assert (string= "subject" (cadr result))))) + +(defun icalendar-testsuite--test-convert-yearly-to-ical () + "Test method for `icalendar--convert-yearly-to-ical'." + (let* ((calendar-date-style 'iso) + result + (calendar-month-name-array + ["January" "February" "March" "April" "May" "June" "July" "August" + "September" "October" "November" "December"])) + (setq result (icalendar--convert-yearly-to-ical "" "May 1 Tag der Arbeit")) + (assert (= 2 (length result))) + (assert (string= (concat + "\nDTSTART;VALUE=DATE:19000501" + "\nDTEND;VALUE=DATE:19000502" + "\nRRULE:FREQ=YEARLY;INTERVAL=1;BYMONTH=5;BYMONTHDAY=1") + (car result))) + (assert (string= "Tag der Arbeit" (cadr result))))) + +(defun icalendar-testsuite--test-convert-block-to-ical () + "Test method for `icalendar--convert-block-to-ical'." + (let* ((calendar-date-style 'iso) + result) + (setq result (icalendar--convert-block-to-ical + "" "%%(diary-block 2004 7 19 2004 8 27) Sommerferien")) + (assert (= 2 (length result))) + (assert (string= (concat + "\nDTSTART;VALUE=DATE:20040719" + "\nDTEND;VALUE=DATE:20040828") + (car result))) + (assert (string= "Sommerferien" (cadr result))))) + +(defun icalendar-testsuite--test-convert-cyclic-to-ical () + "Test method for `icalendar--convert-cyclic-to-ical'." + (let* ((calendar-date-style 'iso) + result) + (setq result (icalendar--convert-block-to-ical + "" "%%(diary-block 2004 7 19 2004 8 27) Sommerferien")) + (assert (= 2 (length result))) + (assert (string= (concat + "\nDTSTART;VALUE=DATE:20040719" + "\nDTEND;VALUE=DATE:20040828") + (car result))) + (assert (string= "Sommerferien" (cadr result))))) + +(defun icalendar-testsuite--test-convert-anniversary-to-ical () + "Test method for `icalendar--convert-anniversary-to-ical'." + (let* ((calendar-date-style 'iso) + result) + (setq result (icalendar--convert-anniversary-to-ical + "" "%%(diary-anniversary 1964 6 30) g")) + (assert (= 2 (length result))) + (assert (string= (concat + "\nDTSTART;VALUE=DATE:19640630" + "\nDTEND;VALUE=DATE:19640701" + "\nRRULE:FREQ=YEARLY;INTERVAL=1;BYMONTH=06;BYMONTHDAY=30") + (car result))) + (assert (string= "g" (cadr result))))) + (defun icalendar-testsuite--test-calendar-style () "Test method for `icalendar--date-style'." (dolist (calendar-date-style '(iso american european))