90 |
|
|
91 |
;;; Code: |
;;; Code: |
92 |
|
|
93 |
(defconst icalendar-version 0.09 |
(defconst icalendar-version 0.10 |
94 |
"Version number of icalendar.el.") |
"Version number of icalendar.el.") |
95 |
|
|
96 |
;; ====================================================================== |
;; ====================================================================== |
360 |
(append result (list (list param-name param-value))))))) |
(append result (list (list param-name param-value))))))) |
361 |
result)) |
result)) |
362 |
|
|
363 |
(defun icalendar--decode-isodatetime (isodatetimestring) |
(defun icalendar--decode-isodatetime (isodatetimestring &optional day-shift) |
364 |
"Return ISODATETIMESTRING in format like `decode-time'. |
"Return ISODATETIMESTRING in format like `decode-time'. |
365 |
Converts from ISO-8601 to Emacs representation. If ISODATETIMESTRING |
Converts from ISO-8601 to Emacs representation. If |
366 |
specifies UTC time (trailing letter Z) the decoded time is given in |
ISODATETIMESTRING specifies UTC time (trailing letter Z) the |
367 |
the local time zone! FIXME: TZID-attributes are ignored....! FIXME: |
decoded time is given in the local time zone! If optional |
368 |
multiple comma-separated values should be allowed!" |
parameter DAY-SHIFT is non-nil the result is shifted by DAY-SHIFT |
369 |
|
days. |
370 |
|
|
371 |
|
FIXME: TZID-attributes are ignored....! |
372 |
|
FIXME: multiple comma-separated values should be allowed!" |
373 |
(icalendar--dmsg isodatetimestring) |
(icalendar--dmsg isodatetimestring) |
374 |
(if isodatetimestring |
(if isodatetimestring |
375 |
;; day/month/year must be present |
;; day/month/year must be present |
391 |
(char-equal ?Z (aref isodatetimestring 15))) |
(char-equal ?Z (aref isodatetimestring 15))) |
392 |
;; if not UTC add current-time-zone offset |
;; if not UTC add current-time-zone offset |
393 |
(setq second (+ (car (current-time-zone)) second))) |
(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)))) |
403 |
;; create the decoded date-time |
;; create the decoded date-time |
404 |
;; FIXME!?! |
;; FIXME!?! |
405 |
(condition-case nil |
(condition-case nil |
1096 |
|
|
1097 |
;; we're done, insert everything into the file |
;; we're done, insert everything into the file |
1098 |
(save-current-buffer |
(save-current-buffer |
1099 |
(let ((coding-system-for-write 'utf8)) |
(let ((coding-system-for-write 'utf-8)) |
1100 |
(set-buffer (find-file ical-filename)) |
(set-buffer (find-file ical-filename)) |
1101 |
(goto-char (point-max)) |
(goto-char (point-max)) |
1102 |
(insert "BEGIN:VCALENDAR") |
(insert "BEGIN:VCALENDAR") |
1297 |
(unt |
(unt |
1298 |
(icalendar--datetime-to-diary-date |
(icalendar--datetime-to-diary-date |
1299 |
(icalendar--decode-isodatetime |
(icalendar--decode-isodatetime |
1300 |
until)))) |
until -1)))) |
1301 |
(setq diary-string |
(setq diary-string |
1302 |
(format |
(format |
1303 |
(concat "%%%%(and " |
(concat "%%%%(and " |
1310 |
dtstart) |
dtstart) |
1311 |
(icalendar--datetime-to-diary-date |
(icalendar--datetime-to-diary-date |
1312 |
(icalendar--decode-isodatetime |
(icalendar--decode-isodatetime |
1313 |
until))))) |
until -1))))) |
1314 |
(setq diary-string |
(setq diary-string |
1315 |
(format "%%%%(and (diary-cyclic %d %s))" |
(format "%%%%(and (diary-cyclic %d %s))" |
1316 |
(* interval 7) |
(* interval 7) |
1382 |
e 'DTSTART)))) |
e 'DTSTART)))) |
1383 |
(de (icalendar--datetime-to-diary-date |
(de (icalendar--datetime-to-diary-date |
1384 |
(icalendar--decode-isodatetime |
(icalendar--decode-isodatetime |
1385 |
until)))) |
until -1)))) |
1386 |
(setq diary-string |
(setq diary-string |
1387 |
(format |
(format |
1388 |
"%%%%(and (diary-block %s %s))" |
"%%%%(and (diary-block %s %s))" |
1419 |
(format "......")))) |
(format "......")))) |
1420 |
(icalendar--split-value rdate))) |
(icalendar--split-value rdate))) |
1421 |
;; non-recurring event |
;; non-recurring event |
1422 |
;; long event |
;; all-day event |
1423 |
((not (string= start-d end-d)) |
((not (string= start-d end-d)) |
1424 |
(icalendar--dmsg "non-recurring event") |
(icalendar--dmsg "non-recurring event") |
1425 |
(let ((ds (icalendar--datetime-to-diary-date dtstart)) |
(let ((ds (icalendar--datetime-to-diary-date dtstart)) |
1426 |
(de (icalendar--datetime-to-diary-date dtend))) |
(de (icalendar--datetime-to-diary-date |
1427 |
|
(icalendar--decode-isodatetime |
1428 |
|
(icalendar--get-event-property e 'DTEND) |
1429 |
|
-1)))) |
1430 |
(setq diary-string |
(setq diary-string |
1431 |
(format "%%%%(and (diary-block %s %s))" |
(format "%%%%(and (diary-block %s %s))" |
1432 |
ds de))) |
ds de))) |