Skip to content

Commit

Permalink
Added support for rrule
Browse files Browse the repository at this point in the history
  • Loading branch information
peterbraden committed Apr 23, 2013
1 parent 10e2c9b commit 985abf4
Show file tree
Hide file tree
Showing 5 changed files with 24 additions and 0 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
node_modules
8 changes: 8 additions & 0 deletions node-ical.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,3 +16,11 @@ exports.fromURL = function(url, opts, cb){
exports.parseFile = function(filename){
return ical.parseICS(fs.readFileSync(filename, 'utf8'))
}


var rrule = require('rrule').RRule

ical.objectHandlers['RRULE'] = function(val, params, curr, par, line){
curr['rrule'] = rrule.fromString(line.replace("RRULE:", ""));
return curr
}
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
, "repository": {"type" : "git", "url" : "git:https://github.com/peterbraden/ical.js.git"}
, "dependencies": {
"request": ""
, "rrule": "1.0.1"
}
, "devDependencies": {
"vows" : "0.7.0"
Expand Down
13 changes: 13 additions & 0 deletions test/test.js
Original file line number Diff line number Diff line change
Expand Up @@ -176,6 +176,19 @@ vows.describe('node-ical').addBatch({
assert.equal(topic.start.toISOString(), new Date(2011, 07, 04, 12, 0,0).toISOString())
}
}
, 'event with rrule' :{
topic: function(events){
return _.select(_.values(events), function(x){
return x.summary == "foobarTV broadcast starts"
})[0];
}
, "Has an RRULE": function(topic){
assert.notEqual(topic.rrule, undefined);
}
, "RRule text": function(topic){
assert.equal(topic.rrule.toText(), "every 5 weeks on Monday, Friday until January 30, 2013")
}
}
}
, 'url request errors' : {
topic : function () {
Expand Down
1 change: 1 addition & 0 deletions test/test6.ics
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ DTSTAMP;VALUE=DATE:20120214T224612
DTSTART;VALUE=DATE:20110804T120000
LOCATION:foobarTV
SUMMARY:foobarTV broadcast starts
RRULE:FREQ=WEEKLY;BYDAY=MO,FR;INTERVAL=5;UNTIL=20130130T230000Z
URL:https://www.foobartv.net
END:VEVENT
BEGIN:VEVENT
Expand Down

0 comments on commit 985abf4

Please sign in to comment.