Skip to content

Instantly share code, notes, and snippets.

@cabe56
Created May 24, 2014 02:36
Show Gist options
  • Save cabe56/e1e7fa21cc412bdfdba5 to your computer and use it in GitHub Desktop.
Save cabe56/e1e7fa21cc412bdfdba5 to your computer and use it in GitHub Desktop.
Parse .ics file exported from iOS Reminders
%html
%head
%title= 'iCal to CSV converter'
%script(type='text/javascript' src='https://rawgit.com/mozilla-comm/ical.js/master/build/ical.js')
:javascript
// Adapted from http://www.html5rocks.com/en/tutorials/file/dndfiles/
function handleFileSelect(evt) {
var reader = new FileReader();
reader.onload = function (e) {
var comp = new ICAL.Component(ICAL.parse(e.target.result)[1]); // result == ['icalendar', data]
todo_array = comp.getAllSubcomponents('vtodo').map(function(todo){ return new ICAL.Event(todo); });
document.getElementById('file-output-container').innerHTML = JSON.stringify(todo_array[0], undefined, 2);
};
reader.readAsText(evt.target.files[0]);
}
window.onload = function () {
document.getElementById('icalFile').addEventListener('change', handleFileSelect, false);
}
%body.main-container
%input#icalFile(type='file')
#file-output-container
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment