ical.js is a small piece of Javascript code, which generates for download ical calendar files on the client side.
git clone https://github.com/G-ram/ics.js
<script src="ical.js"></script>
###Dependencies
Blob.js - Github
<script src="http://rawgithub.com/eligrey/Blob.js/master/Blob.js"></script>
Filesaver.js - Github
<script src="http://rawgithub.com/eligrey/FileSaver.js/master/FileSaver.js"></script>
var cal = new calendar("g-ram//calendar");
cal.addEvent({
UID: "RaNd0mN0nSeNSe"
DTSTART: new Date(),
DTEND: new Date(new Date().getTime() + 3600000),
SUMMARY: "Test Event",
DESCRIPTION: "This is a test",
LOCATION: "Hamilton 406",
ORGANIZER: "Me",
URL: "http://www.snazzystudios.com",
EXDATE: ICSFormatDate(new Date().getTime() - 1200000)+","+ICSFormatDate(new Date().getTime() + 4800000),
RRULE: "FREQ=WEEKLY;UNTIL="+ICSFormatDate(new Date().getTime() + 3600000)
});
cal.download("MyCalendar")
Use this method to create a new calendar object. PRODID is a string that represent the calendar's PRODID element (see documentation on ICS files for more information)
Add an event. Options is an plain object, that configure the event.
Event UID. If not set, an UID will be generated randomly.
Appointment date of beginning
Appointment date of end
Appointment summary
Appointment description
Appointment location
Appointment organizer
List of dates to exclude for a repeated event (see documentation on ICS files for more information)
Recurrence rule (see documentation on ICS files for more information)
Appointment Website
Downloads the ics file. "filename" is a string that is the name of the ics file to be downloaded. The program will automatically tack on an ".ics" ending to the filename.
Return calendar as a String.
Reset the calender object.
Formats any date object into the format that .ics files require.
ICSFormatDate(new Date(2014,5,1));
##Browser Support
Browser | Constructs as | Filenames | Max Blob Size | Dependencies |
---|---|---|---|---|
Firefox 20+ | Blob | Yes | 800 MiB | None |
Firefox < 20 | data: URI | No | n/a | Blob.js |
Chrome | Blob | Yes | 345 MiB | None |
Chrome for Android | Blob | Yes | ? | None |
IE 10+ | Blob | Yes | 600 MiB | None |
Opera 15+ | Blob | Yes | 345 MiB | None |
Opera < 15 | data: URI | No | n/a | Blob.js |
Safari 6.1+* | Blob | No | ? | None |
Safari < 6 | data: URI | No | n/a | Blob.js |
###Note: Safari may not entirely support this library