/[emacs]/emacs/lisp/calendar/icalendar.el
ViewVC logotype

Diff of /emacs/lisp/calendar/icalendar.el

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1.6 by gm, Fri Feb 11 01:02:56 2005 UTC revision 1.7 by gm, Thu Feb 24 18:22:28 2005 UTC
# Line 90  Line 90 
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  ;; ======================================================================  ;; ======================================================================
# Line 360  children." Line 360  children."
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
# Line 387  multiple comma-separated values should b Line 391  multiple comma-separated values should b
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
# Line 1083  FExport diary data into iCalendar file: Line 1096  FExport diary data into iCalendar file:
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")
# Line 1284  written into the buffer ` *icalendar-err Line 1297  written into the buffer ` *icalendar-err
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 "
# Line 1297  written into the buffer ` *icalendar-err Line 1310  written into the buffer ` *icalendar-err
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)
# Line 1369  written into the buffer ` *icalendar-err Line 1382  written into the buffer ` *icalendar-err
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))"
# Line 1406  written into the buffer ` *icalendar-err Line 1419  written into the buffer ` *icalendar-err
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)))

Legend:
Removed from v.1.6  
changed lines
  Added in v.1.7

savannah-hackers-public@gnu.org
ViewVC Help
Powered by ViewVC 1.1.26