org-e-icalendar: Fix events duration when ending time is specified

* contrib/lisp/org-e-icalendar.el (org-e-icalendar-convert-timestamp):
  Fix events duration when ending time is specified.
This commit is contained in:
Nicolas Goaziou 2012-11-05 15:24:09 +01:00
parent 7d87ed1e4a
commit 11c5faa7dd
1 changed files with 30 additions and 17 deletions

View File

@ -355,29 +355,42 @@ it, in order to make a complete line (e.g. \"DTSTART\").
When optional argument END is non-nil, use end of time range. When optional argument END is non-nil, use end of time range.
Also increase the hour by two (if time string contains a time), Also increase the hour by two (if time string contains a time),
or the day by one (if it does not contain a time). or the day by one (if it does not contain a time) when no
explicit ending time is specified.
When optional argument UTC is non-nil, time will be expressed in When optional argument UTC is non-nil, time will be expressed in
Universal Time, ignoring `org-e-icalendar-date-time-format'. Universal Time, ignoring `org-e-icalendar-date-time-format'.
This is mandatory for \"DTSTAMP\" property." This is mandatory for \"DTSTAMP\" property."
(let* ((with-time-p (org-element-property :minute-start timestamp)) (let* ((year-start (org-element-property :year-start timestamp))
(year-end (org-element-property :year-end timestamp))
(month-start (org-element-property :month-start timestamp))
(month-end (org-element-property :month-end timestamp))
(day-start (org-element-property :day-start timestamp))
(day-end (org-element-property :day-end timestamp))
(hour-start (org-element-property :hour-start timestamp))
(hour-end (org-element-property :hour-end timestamp))
(minute-start (org-element-property :minute-start timestamp))
(minute-end (org-element-property :minute-end timestamp))
(with-time-p minute-start)
(equal-bounds-p
(equal (list year-start month-start day-start hour-start minute-start)
(list year-end month-end day-end hour-end minute-end)))
(mi (cond ((not with-time-p) 0) (mi (cond ((not with-time-p) 0)
((not end) (org-element-property :minute-start timestamp)) ((not end) minute-start)
(org-agenda-default-appointment-duration ((and org-agenda-default-appointment-duration equal-bounds-p)
(+ (org-element-property :minute-end timestamp) (+ minute-end org-agenda-default-appointment-duration))
org-agenda-default-appointment-duration)) (t minute-end)))
(t (org-element-property :minute-end timestamp))))
(h (cond ((not with-time-p) 0) (h (cond ((not with-time-p) 0)
((not end) (org-element-property :hour-start timestamp)) ((not end) hour-start)
(org-agenda-default-appointment-duration ((or (not equal-bounds-p)
(org-element-property :hour-end timestamp)) org-agenda-default-appointment-duration)
(t (+ (org-element-property :hour-end timestamp) 2)))) hour-end)
(d (cond ((not end) (org-element-property :day-start timestamp)) (t (+ hour-end 2))))
((not with-time-p) (d (cond ((not end) day-start)
(1+ (org-element-property :day-end timestamp))) ((not with-time-p) (1+ day-end))
(t (org-element-property :day-end timestamp)))) (t day-end)))
(m (org-element-property (if end :month-end :month-start) timestamp)) (m (if end month-end month-start))
(y (org-element-property (if end :year-end :year-start) timestamp))) (y (if end year-end year-start)))
(concat (concat
keyword keyword
(format-time-string (format-time-string