Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
arolson101 committed Feb 14, 2018
1 parent 9b7c400 commit 0bfeeac
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 1 deletion.
4 changes: 3 additions & 1 deletion lib/rrule.js
Original file line number Diff line number Diff line change
Expand Up @@ -384,6 +384,8 @@
return wdaymask
}())

var WDAYS = ['MO', 'TU', 'WE', 'TH', 'FR', 'SA', 'SU']

// =============================================================================
// Weekday
// =============================================================================
Expand All @@ -409,7 +411,7 @@

// __repr__
toString: function () {
var s = ['MO', 'TU', 'WE', 'TH', 'FR', 'SA', 'SU'][this.weekday]
var s = WDAYS[this.weekday]
if (this.n) s = (this.n > 0 ? '+' : '') + String(this.n) + s
return s
},
Expand Down
22 changes: 22 additions & 0 deletions test/rrule.js
Original file line number Diff line number Diff line change
Expand Up @@ -3502,4 +3502,26 @@ describe('RRule', function () {
'after dtstart , followed by before does not return dtstart')
})
})

it('testConvertAndBack', function () {
[6, RRule.SU].forEach(wkst => {
var rr = new RRule({
dtstart: new Date(Date.UTC(2017, 9, 17, 0, 30, 0, 0)),
until: new Date(Date.UTC(2017, 11, 22, 1, 30, 0, 0)),
freq: RRule.MONTHLY,
interval: 1,
bysetpos: 17,
byweekday: [RRule.SU, RRule.MO, RRule.TU, RRule.WE, RRule.TH, RRule.FR, RRule.SA],
wkst: wkst,
byhour: 11,
byminute: 0,
bysecond: 0
})

var rrstr = rr.toString()
assert.equal(rrstr, 'DTSTART=20171017T003000Z;UNTIL=20171222T013000Z;FREQ=MONTHLY;INTERVAL=1;BYSETPOS=17;BYDAY=SU,MO,TU,WE,TH,FR,SA;WKST=SU;BYHOUR=11;BYMINUTE=0;BYSECOND=0')
var newrr = RRule.fromString(rrstr)
assert.equal(rrstr, newrr.toString())
})
})
})

0 comments on commit 0bfeeac

Please sign in to comment.