Getting fullcalendar events into my daily note

October 6, 2023

The Full Calendar plugin for Obsidian lets me sync my calendars from iCloud into Obsidian, which is helpful, but I’d really like to get today’s events into my Daily Note.


This is how I did that. It’s horrible and hacky and not the fastest performing, but it currently works for me. Though only when the FullCalendar is open, since otherwise it won’t have the data it needs available.

Like most of this sort of jury-rigging, it depends on DataView’s javascript capabilities, but I need to explicitly calculate repeats for events so I need the rrule package for Javascript. The only way I can see to do that is to write a plugin, so I learned to do that, and produced obsidian-rrule

The dataview snippet is below.

//Needed later to decode FullCalendar events for rrule
const DAYS = "UMTWRFS";
//Where FullCalendate keeps its events
let cache = app.plugins.plugins["obsidian-full-calendar"].cache
let filedate = dv.date(dv.current().file.cday)
var result= []//I should make this more idomatic, but I'm lazy and it works.
cache.getAllEvents().forEach((x, i) => {
	x.events.forEach((e)=> {
		var event = e.event
		var date = dv.date(event.date)
		if (event.type == "single") {
		  if (date && date.day==filedate.day && date.month==filedate.month && date.year == filedate.year ) {    
			result.push([event.startTime, event.endTime,event.title,event.allDay])
		  }
		} else if (event.type=="rrule") {
		//Recurring event from iCal
					let sd = event.startDate.replace(/-/g,"")
			    let occ = app.plugins.plugins["obsidian-rrule"].between(event.rrule, sd,"0000",filedate.year, filedate.month, filedate.day, filedate.year, filedate.month, filedate.day)
			    if (occ.length>0){
			    		   result.push([event.startTime,event.endTime,event.title,event.allDay])
			    }
		} else if (event.type=="recurring") {
		//FullCalendar note calender recurring event 
					let sd = event.startDate
			    let occ = app.plugins.plugins["obsidian-rrule"].recurringbetween(event.daysOfWeek.map((c) => DAYS.indexOf(c)), event.startRecur, event.endRecur, filedate.year, filedate.month,filedate.day, filedate.year, filedate.month, filedate.day)
			    if (occ.length>0){			    		  result.push([event.startTime,event.endTime,event.title,event.allDay])
			    }
		} 
	})
})	
function calformat(e) {
	if (e[3]) {
		return ["Allday","",e[2]]
	} else {
	  return [e[0],e[1],e[2]]
	}
}
if (result.length==0) {
	dv.el("b","No calendar entries today.")
} {
	dv.table(["Start","End","Event"],result.sort().map(e => calformat(e)))
}
Getting fullcalendar events into my daily note - October 6, 2023 - Colman Reilly