Fix Bug#15408 (icalendar time zone problem)

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.
This commit is contained in:
Ulf Jasper 2014-08-06 20:19:34 +02:00
parent 2416ad64a4
commit 075e911c45
4 changed files with 46 additions and 16 deletions

View 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

View 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

View 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.

View 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'."