]> git.eshelyaron.com Git - emacs.git/commitdiff
Fix Bug#15408 (icalendar time zone problem)
authorUlf Jasper <ulf.jasper@web.de>
Wed, 6 Aug 2014 18:19:34 +0000 (20:19 +0200)
committerUlf Jasper <ulf.jasper@web.de>
Wed, 6 Aug 2014 18:19:34 +0000 (20:19 +0200)
2014-07-30 Christophe Deleuze <christophe.deleuze@free.fr>

* calendar/icalendar.el (icalendar--decode-isodatetime): Use
actual current-time-zone when converting to local time. (Bug#15408)

2014-07-30  Ulf Jasper  <ulf.jasper@web.de>

* automated/icalendar-tests.el (icalendar--decode-isodatetime): New test.

lisp/ChangeLog
lisp/calendar/icalendar.el
test/ChangeLog
test/automated/icalendar-tests.el

index 449983acfc18e44a6f039c559c06d301e29bb8eb..ae2fcc5d11cbd9a279665e8c7dcbd686e162708a 100644 (file)
@@ -1,3 +1,10 @@
+2014-08-06  Ulf Jasper  <ulf.jasper@web.de>
+
+       * calendar/icalendar.el (icalendar--diarytime-to-isotime): 
+       (icalendar--convert-ordinary-to-ical): Allow for missing minutes
+       (Bug#13750).
+
+
 2014-08-05  Lars Magne Ingebrigtsen  <larsi@gnus.org>
 
        * image-mode.el (image-toggle-display-image): Always rescale images
index 9aefcac23141ff64dbd51a0097c83168c4643d7d..ba4ff1c1fa8950ece4efdc58e2895a3483f7a076 100644 (file)
@@ -896,10 +896,16 @@ is not possible it uses the current calendar date style."
 
 (defun icalendar--diarytime-to-isotime (timestring ampmstring)
   "Convert a time like 9:30pm to an iso-conform string like T213000.
-In this example the TIMESTRING would be \"9:30\" and the AMPMSTRING
-would be \"pm\"."
+In this example the TIMESTRING would be \"9:30\" and the
+AMPMSTRING would be \"pm\".  The minutes may be missing as long
+as the colon is missing as well, i.e. \"9\" is allowed as
+TIMESTRING and has the same result as \"9:00\"."
   (if timestring
-      (let ((starttimenum (read (icalendar--rris ":" "" timestring))))
+      (let* ((parts (save-match-data (split-string timestring ":")))
+             (h (car parts))
+             (m (if (cdr parts) (cadr parts)
+                  (if (> (length h) 2) "" "00")))
+             (starttimenum (read (concat h m))))
         ;; take care of am/pm style
         ;; Be sure *not* to convert 12:00pm - 12:59pm to 2400-2459
         (if (and ampmstring (string= "pm" ampmstring) (< starttimenum 1200))
@@ -1231,9 +1237,9 @@ entries.  ENTRY-MAIN is the first line of the diary entry."
   (if (string-match
        (concat nonmarker
                "\\([^ /]+[ /]+[^ /]+[ /]+[^ ]+\\)\\s-*" ; date
-               "\\(\\([0-9][0-9]?:[0-9][0-9]\\)\\([ap]m\\)?" ; start time
+               "\\(\\([0-9][0-9]?\\(:[0-9][0-9]\\)?\\)\\([ap]m\\)?" ; start time
                "\\("
-               "-\\([0-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)
@@ -1250,25 +1256,25 @@ entries.  ENTRY-MAIN is the first line of the diary entry."
                                               (match-beginning 3)
                                               (match-end 3))
                                  nil)
-                               (if (match-beginning 4)
+                               (if (match-beginning 5)
                                    (substring entry-main
-                                              (match-beginning 4)
-                                              (match-end 4))
+                                              (match-beginning 5)
+                                              (match-end 5))
                                  nil)))
              (endtimestring (icalendar--diarytime-to-isotime
-                             (if (match-beginning 6)
-                                 (substring entry-main
-                                            (match-beginning 6)
-                                            (match-end 6))
-                               nil)
                              (if (match-beginning 7)
                                  (substring entry-main
                                             (match-beginning 7)
                                             (match-end 7))
+                               nil)
+                             (if (match-beginning 9)
+                                 (substring entry-main
+                                            (match-beginning 9)
+                                            (match-end 9))
                                nil)))
              (summary (icalendar--convert-string-for-export
-                       (substring entry-main (match-beginning 8)
-                                  (match-end 8)))))
+                       (substring entry-main (match-beginning 10)
+                                  (match-end 10)))))
         (icalendar--dmsg "ordinary %s" entry-main)
 
         (unless startisostring
index 4339dc56ff37ccf907c50d835c3d1f09ba908ad5..a8727fbef2896eab192979a95498f9af63c6dff4 100644 (file)
@@ -1,3 +1,9 @@
+2014-08-06  Ulf Jasper  <ulf.jasper@web.de>
+
+       * automated/icalendar-tests.el
+       (icalendar--convert-ordinary-to-ical),
+       (icalendar--diarytime-to-isotime): More testcases (Bug#13750).
+
 2014-08-03  Glenn Morris  <rgm@gnu.org>
 
        * automated/Makefile.in (check-tar): New rule.
index 0f655232e71967765ddded56448f08ea85a7d048..a3971989831499077e5bcba41c34ec16f1b9203d 100644 (file)
@@ -220,6 +220,15 @@ END:VTIMEZONE
                       (car result)))
     (should (string= "subject" (cadr result)))
 
+    ;; with start time
+    (setq result (icalendar--convert-ordinary-to-ical
+                  "&?" "&2010 2 15 12:34 s"))
+    (should (= 2 (length result)))
+    (should (string=  (concat "\nDTSTART;VALUE=DATE-TIME:20100215T123400"
+                              "\nDTEND;VALUE=DATE-TIME:20100215T133400")
+                      (car result)))
+    (should (string= "s" (cadr result)))
+
     ;; with time
     (setq result (icalendar--convert-ordinary-to-ical
                   "&?" "&2010 2 15 12:34-23:45 s"))
@@ -267,7 +276,9 @@ END:VTIMEZONE
   (should (string= "T120100"
                   (icalendar--diarytime-to-isotime "1201" "pm")))
   (should (string= "T125900"
-                  (icalendar--diarytime-to-isotime "1259" "pm"))))
+                  (icalendar--diarytime-to-isotime "1259" "pm")))
+  (should (string= "T150000"
+                  (icalendar--diarytime-to-isotime "3" "pm"))))
 
 (ert-deftest icalendar--datetime-to-diary-date ()
   "Test method for `icalendar--datetime-to-diary-date'."