aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGlenn Morris2005-02-24 18:22:28 +0000
committerGlenn Morris2005-02-24 18:22:28 +0000
commit8ee7eb6be4ca591adbe263335e1fc4828231e17a (patch)
treed3557e3947ff7561f3f0aa4389ce9ed65e83f80d
parent1a951b51aa7feb4e3abca211b61e84db540cdb2f (diff)
downloademacs-8ee7eb6be4ca591adbe263335e1fc4828231e17a.tar.gz
emacs-8ee7eb6be4ca591adbe263335e1fc4828231e17a.zip
From Ulf Jasper <ulf.jasper@web.de>:
(icalendar--decode-isodatetime): New optional argument DAY-SHIFT. (icalendar-export-region): Fix coding-system-for-write. (icalendar--convert-ical-to-diary): Shift end-day of all-day events by one.
-rw-r--r--lisp/calendar/icalendar.el40
1 files changed, 28 insertions, 12 deletions
diff --git a/lisp/calendar/icalendar.el b/lisp/calendar/icalendar.el
index 2f0be116ed1..fe127be3990 100644
--- a/lisp/calendar/icalendar.el
+++ b/lisp/calendar/icalendar.el
@@ -90,7 +90,7 @@
90 90
91;;; Code: 91;;; Code:
92 92
93(defconst icalendar-version 0.09 93(defconst icalendar-version 0.10
94 "Version number of icalendar.el.") 94 "Version number of icalendar.el.")
95 95
96;; ====================================================================== 96;; ======================================================================
@@ -360,12 +360,16 @@ children."
360 (append result (list (list param-name param-value))))))) 360 (append result (list (list param-name param-value)))))))
361 result)) 361 result))
362 362
363(defun icalendar--decode-isodatetime (isodatetimestring) 363(defun icalendar--decode-isodatetime (isodatetimestring &optional day-shift)
364 "Return ISODATETIMESTRING in format like `decode-time'. 364 "Return ISODATETIMESTRING in format like `decode-time'.
365Converts from ISO-8601 to Emacs representation. If ISODATETIMESTRING 365Converts from ISO-8601 to Emacs representation. If
366specifies UTC time (trailing letter Z) the decoded time is given in 366ISODATETIMESTRING specifies UTC time (trailing letter Z) the
367the local time zone! FIXME: TZID-attributes are ignored....! FIXME: 367decoded time is given in the local time zone! If optional
368multiple comma-separated values should be allowed!" 368parameter DAY-SHIFT is non-nil the result is shifted by DAY-SHIFT
369days.
370
371FIXME: TZID-attributes are ignored....!
372FIXME: multiple comma-separated values should be allowed!"
369 (icalendar--dmsg isodatetimestring) 373 (icalendar--dmsg isodatetimestring)
370 (if isodatetimestring 374 (if isodatetimestring
371 ;; day/month/year must be present 375 ;; day/month/year must be present
@@ -387,6 +391,15 @@ multiple comma-separated values should be allowed!"
387 (char-equal ?Z (aref isodatetimestring 15))) 391 (char-equal ?Z (aref isodatetimestring 15)))
388 ;; if not UTC add current-time-zone offset 392 ;; if not UTC add current-time-zone offset
389 (setq second (+ (car (current-time-zone)) second))) 393 (setq second (+ (car (current-time-zone)) second)))
394 ;; shift if necessary
395 (if day-shift
396 (let ((mdy (calendar-gregorian-from-absolute
397 (+ (calendar-absolute-from-gregorian
398 (list month day year))
399 day-shift))))
400 (setq month (nth 0 mdy))
401 (setq day (nth 1 mdy))
402 (setq year (nth 2 mdy))))
390 ;; create the decoded date-time 403 ;; create the decoded date-time
391 ;; FIXME!?! 404 ;; FIXME!?!
392 (condition-case nil 405 (condition-case nil
@@ -1083,7 +1096,7 @@ FExport diary data into iCalendar file: ")
1083 1096
1084 ;; we're done, insert everything into the file 1097 ;; we're done, insert everything into the file
1085 (save-current-buffer 1098 (save-current-buffer
1086 (let ((coding-system-for-write 'utf8)) 1099 (let ((coding-system-for-write 'utf-8))
1087 (set-buffer (find-file ical-filename)) 1100 (set-buffer (find-file ical-filename))
1088 (goto-char (point-max)) 1101 (goto-char (point-max))
1089 (insert "BEGIN:VCALENDAR") 1102 (insert "BEGIN:VCALENDAR")
@@ -1284,7 +1297,7 @@ written into the buffer ` *icalendar-errors*'."
1284 (unt 1297 (unt
1285 (icalendar--datetime-to-diary-date 1298 (icalendar--datetime-to-diary-date
1286 (icalendar--decode-isodatetime 1299 (icalendar--decode-isodatetime
1287 until)))) 1300 until -1))))
1288 (setq diary-string 1301 (setq diary-string
1289 (format 1302 (format
1290 (concat "%%%%(and " 1303 (concat "%%%%(and "
@@ -1297,7 +1310,7 @@ written into the buffer ` *icalendar-errors*'."
1297 dtstart) 1310 dtstart)
1298 (icalendar--datetime-to-diary-date 1311 (icalendar--datetime-to-diary-date
1299 (icalendar--decode-isodatetime 1312 (icalendar--decode-isodatetime
1300 until))))) 1313 until -1)))))
1301 (setq diary-string 1314 (setq diary-string
1302 (format "%%%%(and (diary-cyclic %d %s))" 1315 (format "%%%%(and (diary-cyclic %d %s))"
1303 (* interval 7) 1316 (* interval 7)
@@ -1369,7 +1382,7 @@ written into the buffer ` *icalendar-errors*'."
1369 e 'DTSTART)))) 1382 e 'DTSTART))))
1370 (de (icalendar--datetime-to-diary-date 1383 (de (icalendar--datetime-to-diary-date
1371 (icalendar--decode-isodatetime 1384 (icalendar--decode-isodatetime
1372 until)))) 1385 until -1))))
1373 (setq diary-string 1386 (setq diary-string
1374 (format 1387 (format
1375 "%%%%(and (diary-block %s %s))" 1388 "%%%%(and (diary-block %s %s))"
@@ -1406,11 +1419,14 @@ written into the buffer ` *icalendar-errors*'."
1406 (format "......")))) 1419 (format "......"))))
1407 (icalendar--split-value rdate))) 1420 (icalendar--split-value rdate)))
1408 ;; non-recurring event 1421 ;; non-recurring event
1409 ;; long event 1422 ;; all-day event
1410 ((not (string= start-d end-d)) 1423 ((not (string= start-d end-d))
1411 (icalendar--dmsg "non-recurring event") 1424 (icalendar--dmsg "non-recurring event")
1412 (let ((ds (icalendar--datetime-to-diary-date dtstart)) 1425 (let ((ds (icalendar--datetime-to-diary-date dtstart))
1413 (de (icalendar--datetime-to-diary-date dtend))) 1426 (de (icalendar--datetime-to-diary-date
1427 (icalendar--decode-isodatetime
1428 (icalendar--get-event-property e 'DTEND)
1429 -1))))
1414 (setq diary-string 1430 (setq diary-string
1415 (format "%%%%(and (diary-block %s %s))" 1431 (format "%%%%(and (diary-block %s %s))"
1416 ds de))) 1432 ds de)))