diff options
Diffstat (limited to 'model_fs.js')
-rw-r--r-- | model_fs.js | 22 |
1 files changed, 13 insertions, 9 deletions
diff --git a/model_fs.js b/model_fs.js index 3e2af12..23d113f 100644 --- a/model_fs.js +++ b/model_fs.js @@ -97,19 +97,23 @@ exports.rebuildFiles = function() { if(err) { throw err; } }); } else if(events['type'] == 'ical') { - ical.fromURL(events['url'], {}, function(err, data) { + ical.fromURL(events['url'], {}, function(err, bloat) { if(err) { throw err; } + var bDate = new Date(); + var fDate = new Date(); + bDate.setMinutes(bDate.getMinutes() - events['before']); + fDate.setMinutes(bDate.getMinutes() + events['after']); + var data = ical.events_between(bDate, fDate); var compEv = []; for (var k in data) { - if (data.hasOwnProperty(k)) { - var ev = data[k]; - if(ev.start && ev.summary) { - var curDate = new Date(ev.start); - if(typeof compEv[curDate.toDateString()] == "undefined") { - compEv[curDate.toDateString()] = []; - } - compEv[curDate.toDateString()].push({time: curDate.toTimeString(), text: ev.summary}); + if (!data.hasOwnProperty(k)) { continue; } + var ev = data[k]; + ev.time = ev.start.toTimeString(); + if(ev.start && ev.summary) { + if(typeof compEv[ev.start.toDateString()] == "undefined") { + compEv[ev.start.toDateString()] = []; } + compEv[ev.start.toDateString()].push(ev); } } setEvents(slideset, compEv, function(err) { |