From: Ulf Jasper Date: Wed, 6 Aug 2014 18:19:34 +0000 (+0200) Subject: Fix Bug#15408 (icalendar time zone problem) X-Git-Tag: emacs-25.0.90~2635^2~679^2~515 X-Git-Url: http://git.eshelyaron.com/gitweb/?a=commitdiff_plain;h=075e911c4577f587e528632b0c7aa2bd7b5416ec;p=emacs.git Fix Bug#15408 (icalendar time zone problem) 2014-07-30 Christophe Deleuze * calendar/icalendar.el (icalendar--decode-isodatetime): Use actual current-time-zone when converting to local time. (Bug#15408) 2014-07-30 Ulf Jasper * automated/icalendar-tests.el (icalendar--decode-isodatetime): New test. --- diff --git a/lisp/ChangeLog b/lisp/ChangeLog index 449983acfc1..ae2fcc5d11c 100644 --- a/lisp/ChangeLog +++ b/lisp/ChangeLog @@ -1,3 +1,10 @@ +2014-08-06 Ulf Jasper + + * calendar/icalendar.el (icalendar--diarytime-to-isotime): + (icalendar--convert-ordinary-to-ical): Allow for missing minutes + (Bug#13750). + + 2014-08-05 Lars Magne Ingebrigtsen * image-mode.el (image-toggle-display-image): Always rescale images diff --git a/lisp/calendar/icalendar.el b/lisp/calendar/icalendar.el index 9aefcac2314..ba4ff1c1fa8 100644 --- a/lisp/calendar/icalendar.el +++ b/lisp/calendar/icalendar.el @@ -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 diff --git a/test/ChangeLog b/test/ChangeLog index 4339dc56ff3..a8727fbef28 100644 --- a/test/ChangeLog +++ b/test/ChangeLog @@ -1,3 +1,9 @@ +2014-08-06 Ulf Jasper + + * automated/icalendar-tests.el + (icalendar--convert-ordinary-to-ical), + (icalendar--diarytime-to-isotime): More testcases (Bug#13750). + 2014-08-03 Glenn Morris * automated/Makefile.in (check-tar): New rule. diff --git a/test/automated/icalendar-tests.el b/test/automated/icalendar-tests.el index 0f655232e71..a3971989831 100644 --- a/test/automated/icalendar-tests.el +++ b/test/automated/icalendar-tests.el @@ -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'."