emacs-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Emacs-diffs] /srv/bzr/emacs/trunk r99536: Fixed bug#5549 (icalendar.el)


From: Ulf Jasper
Subject: [Emacs-diffs] /srv/bzr/emacs/trunk r99536: Fixed bug#5549 (icalendar.el)
Date: Fri, 19 Feb 2010 19:59:00 +0100
User-agent: Bazaar (2.0.3)

------------------------------------------------------------
revno: 99536
committer: Ulf Jasper <address@hidden>
branch nick: trunk
timestamp: Fri 2010-02-19 19:59:00 +0100
message:
  Fixed bug#5549 (icalendar.el)
modified:
  lisp/ChangeLog
  lisp/calendar/icalendar.el
  test/ChangeLog
  test/icalendar-testsuite.el
=== modified file 'lisp/ChangeLog'
--- a/lisp/ChangeLog    2010-02-19 04:55:31 +0000
+++ b/lisp/ChangeLog    2010-02-19 18:59:00 +0000
@@ -1,3 +1,13 @@
+2010-02-19  Ulf Jasper  <address@hidden>
+
+       * 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  <address@hidden>
 
        * progmodes/gdb-ui.el (gdb-assembler-handler): Accommodate change

=== modified file 'lisp/calendar/icalendar.el'
--- a/lisp/calendar/icalendar.el        2010-01-13 08:35:10 +0000
+++ b/lisp/calendar/icalendar.el        2010-02-19 18:59:00 +0000
@@ -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)

=== modified file 'test/ChangeLog'
--- a/test/ChangeLog    2010-01-18 04:39:40 +0000
+++ b/test/ChangeLog    2010-02-19 18:59:00 +0000
@@ -1,3 +1,16 @@
+2010-02-19  Ulf Jasper  <address@hidden>
+
+       * 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  <address@hidden>
 
        * cedet/semantic-tests.el (semanticdb-test-gnu-global)

=== modified file 'test/icalendar-testsuite.el'
--- a/test/icalendar-testsuite.el       2010-01-13 08:35:10 +0000
+++ b/test/icalendar-testsuite.el       2010-02-19 18:59:00 +0000
@@ -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))


reply via email to

[Prev in Thread] Current Thread [Next in Thread]