Awesome Open Source
Awesome Open Source

Read, Process and Create iCalendar Data and Files

Utilities for handling icalendar data. The package is written in pure R, with no strict dependencies (package ‘base64enc’ is only needed if calendar files have attachments). The package maps iCalendar dates and date-times to R’s native ‘Date’ and ‘POSIXct’ classes. Recurring items can be expanded. Timezones are supported.

Installation

To install the package from a running R session, type:

install.packages('icalutils, type = 'source',
                 repos = c('http://enricoschumann.net/R',
                           getOption('repos')))

or clone/build the GitHub version.

Examples

library("icalutils")
as.data.frame(read_icalendar("/path/to/file"))

Computing recurring events (such as birthdays):

as.data.frame(read_calendar("/path/to/file"), 
              recur.expand = TRUE,
              recur.until = Sys.Date + 30) ## events in next 30 days

Recurrence sets can be computed with function rrule.

 rrule(dtstart = as.Date("2019-12-01"),
	dtend   = as.Date("2019-12-01"),
	freq = "yearly",
	count = 5)
$text
[1] "FREQ=yearly;COUNT=5;INTERVAL=1"

$recurrence_set
     DTSTART      DTEND
1 2019-12-01 2019-12-01
2 2020-12-01 2020-12-01
3 2021-12-01 2021-12-01
4 2022-12-01 2022-12-01
5 2023-12-01 2023-12-01

Setting up a daily email.

library("icalutils")
library("mailtools")  ## https://github.com/enricoschumann/mailtools 

file <- "/path/to/file"
lookahead <- 30

ic <- read_icalendar(file, components = "VEVENT")

df <- as.data.frame(ic, 
		      recur.expand = TRUE,
		      recur.until = Sys.Date() + lookahead)
df <- df[df$start >= as.POSIXct(paste(Sys.Date(), "00:00:00")) &
	   df$start <  as.POSIXct(Sys.Date() + lookahead), ]

df <- df[order(df$start), ]
start <- as.Date(df$start, tz = "")
end <- as.Date(df$end, tz = "")

dt <- as.character(start)
ii <- start != end
dt[ii] <- paste(as.character(start[ii]), "--", as.character(end[ii]))
dt

sendmail(subject = "Kalender",
	   body = c("",
		    paste("Calendar entries for the next", lookahead,  "days"),
		    "",
		    "",
		    paste0(substr(format(df$summary, width = 25), 1, 40),
			   "  [", dt, "]"),
		    ""),

	   method   = "sendemail",
	   to       = "<[email protected]>",
	   from     = "<[email protected]>",
	   port     = 587,
	   server   = "<server.net>",
	   user     = "<username>",
	   password = "",
	   headers  = "X-MAIL-CATEGORY: daily calendar report")


Get A Weekly Email With Trending Projects For These Topics
No Spam. Unsubscribe easily at any time.
R (71,667
Ical (146
Icalendar (146
Related Projects