Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rudimentary support for diary sexp and rrule #216

Open
wants to merge 5 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
44 changes: 27 additions & 17 deletions org-caldav.el
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@
(require 'url-util)
(require 'cl-lib)
(require 'button)
(require `subr-x)


(defgroup org-caldav nil
Expand Down Expand Up @@ -1281,7 +1282,9 @@ match org-caldav-skip-conditions."
(defun org-caldav-generate-ics ()
"Generate ICS file from `org-caldav-files'.
Returns buffer containing the ICS file."
(let ((icalendar-file
(let ((calendar-date-style 'european)
(org-icalendar-with-timestamps 't)
(icalendar-file
(if (featurep 'ox-icalendar)
'org-icalendar-combined-agenda-file
'org-combined-agenda-icalendar-file))
Expand Down Expand Up @@ -1453,21 +1456,22 @@ Returns MD5 from entry."
(defun org-caldav-insert-org-time-stamp (date &optional time)
"Insert org time stamp using DATE and TIME at point.
DATE is given as european date (DD MM YYYY)."
(let* ((stime (when time (mapcar 'string-to-number
(split-string time ":"))))
(hours (if time (car stime) 0))
(minutes (if time (nth 1 stime) 0))
(sdate (mapcar 'string-to-number (split-string date)))
(day (car sdate))
(month (nth 1 sdate))
(year (nth 2 sdate))
(internaltime (encode-time 0 minutes hours day month year)))
(insert
(concat "<"
(if time
(format-time-string "%Y-%m-%d %a %H:%M" internaltime)
(format-time-string "%Y-%m-%d %a" internaltime))
">"))))
(cond ((string-match-p "^%%" date) (insert "<" date ">"))
(t (let* ((stime (when time (mapcar 'string-to-number
(split-string time ":"))))
(hours (if time (car stime) 0))
(minutes (if time (nth 1 stime) 0))
(sdate (mapcar 'string-to-number (split-string date)))
(day (car sdate))
(month (nth 1 sdate))
(year (nth 2 sdate))
(internaltime (encode-time 0 minutes hours day month year)))
(insert
(concat "<"
(if time
(format-time-string "%Y-%m-%d %a %H:%M" internaltime)
(format-time-string "%Y-%m-%d %a" internaltime))
">"))))))

(defun org-caldav-save-sync-state ()
"Save org-caldav sync database to disk.
Expand Down Expand Up @@ -1651,7 +1655,7 @@ which can be fed into `org-caldav-insert-org-entry'."
(summary (icalendar--convert-string-for-import
(or (icalendar--get-event-property e 'SUMMARY)
"No Title")))
e-type
e-type
(description (icalendar--convert-string-for-import
(or (icalendar--get-event-property e 'DESCRIPTION)
"")))
Expand Down Expand Up @@ -1700,6 +1704,12 @@ which can be fed into `org-caldav-insert-org-entry'."
"DATE")))
(icalendar--datetime-to-colontime dtend-dec)
start-t))
(when rrule
(setq start-d (string-trim (icalendar--convert-recurring-to-diary e dtstart-dec start-t end-t))
end-1-d nil
end-d nil
end-t nil)
)
;; Return result
(list start-d start-t
(if end-t end-d end-1-d)
Expand Down