diff options
| author | Ulf Jasper | 2014-08-06 20:19:34 +0200 |
|---|---|---|
| committer | Ulf Jasper | 2014-08-06 20:19:34 +0200 |
| commit | 075e911c4577f587e528632b0c7aa2bd7b5416ec (patch) | |
| tree | 1b9ec013ed1a18b6a4e12cc8e622751fdcd902dd | |
| parent | 2416ad64a4e47094ad26c254a85addbf28211910 (diff) | |
| download | emacs-075e911c4577f587e528632b0c7aa2bd7b5416ec.tar.gz emacs-075e911c4577f587e528632b0c7aa2bd7b5416ec.zip | |
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.
| -rw-r--r-- | lisp/ChangeLog | 7 | ||||
| -rw-r--r-- | lisp/calendar/icalendar.el | 36 | ||||
| -rw-r--r-- | test/ChangeLog | 6 | ||||
| -rw-r--r-- | test/automated/icalendar-tests.el | 13 |
4 files changed, 46 insertions, 16 deletions
diff --git a/lisp/ChangeLog b/lisp/ChangeLog index 449983acfc1..ae2fcc5d11c 100644 --- a/lisp/ChangeLog +++ b/lisp/ChangeLog | |||
| @@ -1,3 +1,10 @@ | |||
| 1 | 2014-08-06 Ulf Jasper <ulf.jasper@web.de> | ||
| 2 | |||
| 3 | * calendar/icalendar.el (icalendar--diarytime-to-isotime): | ||
| 4 | (icalendar--convert-ordinary-to-ical): Allow for missing minutes | ||
| 5 | (Bug#13750). | ||
| 6 | |||
| 7 | |||
| 1 | 2014-08-05 Lars Magne Ingebrigtsen <larsi@gnus.org> | 8 | 2014-08-05 Lars Magne Ingebrigtsen <larsi@gnus.org> |
| 2 | 9 | ||
| 3 | * image-mode.el (image-toggle-display-image): Always rescale images | 10 | * 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." | |||
| 896 | 896 | ||
| 897 | (defun icalendar--diarytime-to-isotime (timestring ampmstring) | 897 | (defun icalendar--diarytime-to-isotime (timestring ampmstring) |
| 898 | "Convert a time like 9:30pm to an iso-conform string like T213000. | 898 | "Convert a time like 9:30pm to an iso-conform string like T213000. |
| 899 | In this example the TIMESTRING would be \"9:30\" and the AMPMSTRING | 899 | In this example the TIMESTRING would be \"9:30\" and the |
| 900 | would be \"pm\"." | 900 | AMPMSTRING would be \"pm\". The minutes may be missing as long |
| 901 | as the colon is missing as well, i.e. \"9\" is allowed as | ||
| 902 | TIMESTRING and has the same result as \"9:00\"." | ||
| 901 | (if timestring | 903 | (if timestring |
| 902 | (let ((starttimenum (read (icalendar--rris ":" "" timestring)))) | 904 | (let* ((parts (save-match-data (split-string timestring ":"))) |
| 905 | (h (car parts)) | ||
| 906 | (m (if (cdr parts) (cadr parts) | ||
| 907 | (if (> (length h) 2) "" "00"))) | ||
| 908 | (starttimenum (read (concat h m)))) | ||
| 903 | ;; take care of am/pm style | 909 | ;; take care of am/pm style |
| 904 | ;; Be sure *not* to convert 12:00pm - 12:59pm to 2400-2459 | 910 | ;; Be sure *not* to convert 12:00pm - 12:59pm to 2400-2459 |
| 905 | (if (and ampmstring (string= "pm" ampmstring) (< starttimenum 1200)) | 911 | (if (and ampmstring (string= "pm" ampmstring) (< starttimenum 1200)) |
| @@ -1231,9 +1237,9 @@ entries. ENTRY-MAIN is the first line of the diary entry." | |||
| 1231 | (if (string-match | 1237 | (if (string-match |
| 1232 | (concat nonmarker | 1238 | (concat nonmarker |
| 1233 | "\\([^ /]+[ /]+[^ /]+[ /]+[^ ]+\\)\\s-*" ; date | 1239 | "\\([^ /]+[ /]+[^ /]+[ /]+[^ ]+\\)\\s-*" ; date |
| 1234 | "\\(\\([0-9][0-9]?:[0-9][0-9]\\)\\([ap]m\\)?" ; start time | 1240 | "\\(\\([0-9][0-9]?\\(:[0-9][0-9]\\)?\\)\\([ap]m\\)?" ; start time |
| 1235 | "\\(" | 1241 | "\\(" |
| 1236 | "-\\([0-9][0-9]?:[0-9][0-9]\\)\\([ap]m\\)?\\)?" ; end time | 1242 | "-\\([0-9][0-9]?\\(:[0-9][0-9]\\)?\\)\\([ap]m\\)?\\)?" ; end time |
| 1237 | "\\)?" | 1243 | "\\)?" |
| 1238 | "\\s-*\\(.*?\\) ?$") | 1244 | "\\s-*\\(.*?\\) ?$") |
| 1239 | entry-main) | 1245 | entry-main) |
| @@ -1250,25 +1256,25 @@ entries. ENTRY-MAIN is the first line of the diary entry." | |||
| 1250 | (match-beginning 3) | 1256 | (match-beginning 3) |
| 1251 | (match-end 3)) | 1257 | (match-end 3)) |
| 1252 | nil) | 1258 | nil) |
| 1253 | (if (match-beginning 4) | 1259 | (if (match-beginning 5) |
| 1254 | (substring entry-main | 1260 | (substring entry-main |
| 1255 | (match-beginning 4) | 1261 | (match-beginning 5) |
| 1256 | (match-end 4)) | 1262 | (match-end 5)) |
| 1257 | nil))) | 1263 | nil))) |
| 1258 | (endtimestring (icalendar--diarytime-to-isotime | 1264 | (endtimestring (icalendar--diarytime-to-isotime |
| 1259 | (if (match-beginning 6) | ||
| 1260 | (substring entry-main | ||
| 1261 | (match-beginning 6) | ||
| 1262 | (match-end 6)) | ||
| 1263 | nil) | ||
| 1264 | (if (match-beginning 7) | 1265 | (if (match-beginning 7) |
| 1265 | (substring entry-main | 1266 | (substring entry-main |
| 1266 | (match-beginning 7) | 1267 | (match-beginning 7) |
| 1267 | (match-end 7)) | 1268 | (match-end 7)) |
| 1269 | nil) | ||
| 1270 | (if (match-beginning 9) | ||
| 1271 | (substring entry-main | ||
| 1272 | (match-beginning 9) | ||
| 1273 | (match-end 9)) | ||
| 1268 | nil))) | 1274 | nil))) |
| 1269 | (summary (icalendar--convert-string-for-export | 1275 | (summary (icalendar--convert-string-for-export |
| 1270 | (substring entry-main (match-beginning 8) | 1276 | (substring entry-main (match-beginning 10) |
| 1271 | (match-end 8))))) | 1277 | (match-end 10))))) |
| 1272 | (icalendar--dmsg "ordinary %s" entry-main) | 1278 | (icalendar--dmsg "ordinary %s" entry-main) |
| 1273 | 1279 | ||
| 1274 | (unless startisostring | 1280 | (unless startisostring |
diff --git a/test/ChangeLog b/test/ChangeLog index 4339dc56ff3..a8727fbef28 100644 --- a/test/ChangeLog +++ b/test/ChangeLog | |||
| @@ -1,3 +1,9 @@ | |||
| 1 | 2014-08-06 Ulf Jasper <ulf.jasper@web.de> | ||
| 2 | |||
| 3 | * automated/icalendar-tests.el | ||
| 4 | (icalendar--convert-ordinary-to-ical), | ||
| 5 | (icalendar--diarytime-to-isotime): More testcases (Bug#13750). | ||
| 6 | |||
| 1 | 2014-08-03 Glenn Morris <rgm@gnu.org> | 7 | 2014-08-03 Glenn Morris <rgm@gnu.org> |
| 2 | 8 | ||
| 3 | * automated/Makefile.in (check-tar): New rule. | 9 | * 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 | |||
| 220 | (car result))) | 220 | (car result))) |
| 221 | (should (string= "subject" (cadr result))) | 221 | (should (string= "subject" (cadr result))) |
| 222 | 222 | ||
| 223 | ;; with start time | ||
| 224 | (setq result (icalendar--convert-ordinary-to-ical | ||
| 225 | "&?" "&2010 2 15 12:34 s")) | ||
| 226 | (should (= 2 (length result))) | ||
| 227 | (should (string= (concat "\nDTSTART;VALUE=DATE-TIME:20100215T123400" | ||
| 228 | "\nDTEND;VALUE=DATE-TIME:20100215T133400") | ||
| 229 | (car result))) | ||
| 230 | (should (string= "s" (cadr result))) | ||
| 231 | |||
| 223 | ;; with time | 232 | ;; with time |
| 224 | (setq result (icalendar--convert-ordinary-to-ical | 233 | (setq result (icalendar--convert-ordinary-to-ical |
| 225 | "&?" "&2010 2 15 12:34-23:45 s")) | 234 | "&?" "&2010 2 15 12:34-23:45 s")) |
| @@ -267,7 +276,9 @@ END:VTIMEZONE | |||
| 267 | (should (string= "T120100" | 276 | (should (string= "T120100" |
| 268 | (icalendar--diarytime-to-isotime "1201" "pm"))) | 277 | (icalendar--diarytime-to-isotime "1201" "pm"))) |
| 269 | (should (string= "T125900" | 278 | (should (string= "T125900" |
| 270 | (icalendar--diarytime-to-isotime "1259" "pm")))) | 279 | (icalendar--diarytime-to-isotime "1259" "pm"))) |
| 280 | (should (string= "T150000" | ||
| 281 | (icalendar--diarytime-to-isotime "3" "pm")))) | ||
| 271 | 282 | ||
| 272 | (ert-deftest icalendar--datetime-to-diary-date () | 283 | (ert-deftest icalendar--datetime-to-diary-date () |
| 273 | "Test method for `icalendar--datetime-to-diary-date'." | 284 | "Test method for `icalendar--datetime-to-diary-date'." |