Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

rrule

Package Overview
Dependencies
Maintainers
1
Versions
40
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

rrule - npm Package Compare versions

Comparing version 2.0.1 to 2.1.0

9

bower.json
{
"name": "rrule",
"description": "JavaScript library for working with recurrence rules for calendar dates.",
"homepage": "http://jkbr.github.io/rrule/",
"homepage": "http://jakubroztocil.github.io/rrule/",
"keywords": [

@@ -14,3 +14,3 @@ "dates",

"type": "git",
"url": "git://github.com/jkbr/rrule.git"
"url": "git://github.com/jakubroztocil/rrule.git"
},

@@ -33,6 +33,3 @@

"components"
],
"dependencies": {
"underscore": ">= 1.3.3"
}
]
}
/*!
* rrule.js - Library for working with recurrence rules for calendar dates.
* https://github.com/jkbr/rrule
* https://github.com/jakubroztocil/rrule
*
* Copyright 2010, Jakub Roztocil and Lars Schoning
* Licenced under the BSD licence.
* https://github.com/jkbr/rrule/blob/master/LICENCE
* https://github.com/jakubroztocil/rrule/blob/master/LICENCE
*

@@ -24,16 +24,13 @@ */

var serverSide = typeof module !== 'undefined' && module.exports;
var _, RRule;
var RRule;
if (serverSide) {
_ = require('underscore');
RRule = require('./rrule').RRule;
} else if (root.RRule || root._) {
} else if (root.RRule) {
RRule = root.RRule;
_ = root._;
} else if (typeof require !== 'undefined') {
if (!RRule) {RRule = require('rrule');}
if (!_ && (typeof require !== 'undefined')) { _ = require('underscore');}
} else {
throw 'rrule.js and underscore.js are required for rrule/nlp.js to work'
throw new Error('rrule.js is required for rrule/nlp.js to work')
}

@@ -43,2 +40,14 @@

//=============================================================================
// Helper functions
//=============================================================================
/**
* Return true if a value is in an array
*/
var contains = function(arr, val) {
return arr.indexOf(val) != -1;
};
//=============================================================================
// ToText

@@ -86,6 +95,6 @@ //=============================================================================

this.byweekday = {
allWeeks:_.filter(byweekday, function (weekday) {
allWeeks:byweekday.filter(function (weekday) {
return !Boolean(weekday.n);
}),
someWeeks:_.filter(byweekday, function (weekday) {
someWeeks:byweekday.filter(function (weekday) {
return Boolean(weekday.n);

@@ -150,11 +159,11 @@ }),

}
_.each(rrule.origOptions, function(value, key){
if (_.contains(['dtstart', 'wkst', 'freq'], key)) {
for (var key in rrule.origOptions) {
if (contains(['dtstart', 'wkst', 'freq'], key)) {
return true;
}
if (!_.include(ToText.IMPLEMENTED[rrule.options.freq], key)) {
if (!contains(ToText.IMPLEMENTED[rrule.options.freq], key)) {
canConvert = false;
return false;
}
});
}

@@ -466,5 +475,5 @@ return canConvert;

if (finalDelim) {
return delimJoin(_.map(arr, realCallback), delim, finalDelim);
return delimJoin(arr.map(realCallback), delim, finalDelim);
} else {
return _.map(arr, realCallback).join(delim + ' ');
return arr.map(realCallback).join(delim + ' ');
}

@@ -576,3 +585,3 @@

if(ttr.isDone())
throw 'Unexpected end';
throw new Error('Unexpected end');

@@ -643,8 +652,8 @@ switch(ttr.symbol) {

if(ttr.isDone())
throw 'Unexpected end';
throw new Error('Unexpected end');
var wkd;
if(!(wkd = decodeWKD())) {
throw 'Unexpected symbol ' + ttr.symbol
+ ', expected weekday';
throw new Error('Unexpected symbol ' + ttr.symbol
+ ', expected weekday');
}

@@ -680,8 +689,8 @@

if(ttr.isDone())
throw 'Unexpected end';
throw new Error('Unexpected end');
var m;
if(!(m = decodeM())) {
throw 'Unexpected symbol ' + ttr.symbol
+ ', expected month';
throw new Error('Unexpected symbol ' + ttr.symbol
+ ', expected month');
}

@@ -698,3 +707,3 @@

default:
throw 'Unknown symbol';
throw new Error('Unknown symbol');

@@ -753,4 +762,4 @@ }

if(!(n = ttr.accept('number'))) {
throw 'Unexpected symbol ' + ttr.symbol
+ ', expected week number';
throw new Error('Unexpected symbol ' + ttr.symbol
+ ', expected week number');
}

@@ -760,4 +769,4 @@ options.byweekno = [n[0]];

if(!(n = ttr.accept('number'))) {
throw 'Unexpected symbol ' + ttr.symbol
+ '; expected monthday';
throw new Error('Unexpected symbol ' + ttr.symbol
+ '; expected monthday');
}

@@ -845,3 +854,3 @@ options.byweekno.push(n[0]);

if(v < -366 || v > 366)
throw 'Nth out of range: ' + v;
throw new Error('Nth out of range: ' + v);

@@ -872,4 +881,4 @@ ttr.nextSymbol();

if (!(nth = decodeNTH())) {
throw 'Unexpected symbol ' + ttr.symbol
+ '; expected monthday';
throw new Error('Unexpected symbol ' + ttr.symbol
+ '; expected monthday');
}

@@ -890,3 +899,3 @@

if (!date) {
throw 'Cannot parse until date:' + ttr.text;
throw new Error('Cannot parse until date:' + ttr.text);
}

@@ -934,4 +943,5 @@ options.until = new Date(date);

_.each(this.rules, function(rule, name) {
var match;
var match, rule;
for (var name in this.rules) {
rule = this.rules[name];
if(match = rule.exec(p.text)) {

@@ -944,3 +954,3 @@ if(best == null || match[0].length > best[0].length) {

});
}

@@ -988,3 +998,3 @@ if(best != null) {

throw 'expected ' + name + ' but found ' + this.symbol;
throw new Error('expected ' + name + ' but found ' + this.symbol);
};

@@ -991,0 +1001,0 @@

/*!
* rrule.js - Library for working with recurrence rules for calendar dates.
* https://github.com/jkbr/rrule
* https://github.com/jakubroztocil/rrule
*
* Copyright 2010, Jakub Roztocil and Lars Schoning
* Licenced under the BSD licence.
* https://github.com/jkbr/rrule/blob/master/LICENCE
* https://github.com/jakubroztocil/rrule/blob/master/LICENCE
*

@@ -13,3 +13,3 @@ * Based on:

* Copyright (c) 2012 - Tomi Pieviläinen <tomi.pievilainen@iki.fi>
* https://github.com/jkbr/rrule/blob/master/LICENCE
* https://github.com/jakubroztocil/rrule/blob/master/LICENCE
*

@@ -20,14 +20,4 @@ */

var serverSide = typeof module !== 'undefined' && module.exports;
var _;
if (serverSide) {
_ = require('underscore');
} else if (root._) {
_ = root._;
} else if (!_ && (typeof require !== 'undefined')){
//Client needs to load underscore with requirejs.
_ = require('underscore');
}
var getnlp = function() {

@@ -39,4 +29,5 @@ if (!getnlp._nlp) {

} else if (!(getnlp._nlp = root._RRuleNLP)) {
throw 'You need to include rrule/nlp.js ' +
'for fromText/toText to work.'
throw new Error(
'You need to include rrule/nlp.js for fromText/toText to work.'
)
}

@@ -48,3 +39,2 @@ }

//=============================================================================

@@ -340,2 +330,10 @@ // Date utilities

/**
* Return true if a value is in an array
*/
var contains = function(arr, val) {
return arr.indexOf(val) != -1;
};
//=============================================================================

@@ -418,3 +416,3 @@ // Date masks

if (n === 0) {
throw 'Can\'t create weekday with n == 0';
throw new Error('Can\'t create weekday with n == 0');
}

@@ -469,3 +467,2 @@ this.weekday = weekday;

var defaults = _.clone(RRule.DEFAULT_OPTIONS);
options = options || {};

@@ -480,22 +477,30 @@

var invalid = _(options)
.chain()
.keys()
.reject(function(name){
return _.has(defaults, name)
})
.value();
// used by toString()
this.origOptions = {};
var invalid = [],
keys = Object.keys(options),
defaultKeys = Object.keys(RRule.DEFAULT_OPTIONS);
// Shallow copy for origOptions and check for invalid
keys.forEach(function(key) {
this.origOptions[key] = options[key];
if (!contains(defaultKeys, key)) invalid.push(key);
}, this);
if (invalid.length) {
throw 'Invalid options: ' + invalid.join(', ')
throw new Error('Invalid options: ' + invalid.join(', '))
}
if (!RRule.FREQUENCIES[options.freq] && options.byeaster === null) {
throw 'Invalid frequency: ' + String(options.freq)
throw new Error('Invalid frequency: ' + String(options.freq))
}
// used by toString()
this.origOptions = _.clone(options);
var opts;
this.options = opts = _.extend({}, defaults, options);
// Merge in default options
defaultKeys.forEach(function(key) {
if (!contains(keys, key)) options[key] = RRule.DEFAULT_OPTIONS[key];
});
var opts = this.options = options;
if (opts.byeaster !== null) {

@@ -525,3 +530,6 @@ opts.freq = RRule.YEARLY;

if (v == 0 || !(-366 <= v && v <= 366)) {
throw 'bysetpos must be between 1 and 366, or between -366 and -1';
throw new Error(
'bysetpos must be between 1 and 366,' +
' or between -366 and -1'
);
}

@@ -738,8 +746,11 @@ }

RRule.optionsToString = function(options) {
var key, keys, value, strValues, pairs = [];
var key, keys, defaultKeys, value, strValues, pairs = [];
keys = _.intersection(_.keys(RRule.DEFAULT_OPTIONS), _.keys(options));
keys = Object.keys(options);
defaultKeys = Object.keys(RRule.DEFAULT_OPTIONS);
for (var i = 0; i < keys.length; i++) {
if (!contains(defaultKeys, keys[i])) continue;
key = keys[i].toUpperCase();

@@ -1077,5 +1088,5 @@ value = options[keys[i]];

gettimeset = gettimeset[freq];
if ((freq >= RRule.HOURLY && plb(byhour) && !_.include(byhour, hour)) ||
(freq >= RRule.MINUTELY && plb(byminute) && !_.include(byminute, minute)) ||
(freq >= RRule.SECONDLY && plb(bysecond) && !_.include(bysecond, minute)))
if ((freq >= RRule.HOURLY && plb(byhour) && !contains(byhour, hour)) ||
(freq >= RRule.MINUTELY && plb(byminute) && !contains(byminute, minute)) ||
(freq >= RRule.SECONDLY && plb(bysecond) && !contains(bysecond, minute)))
{

@@ -1106,11 +1117,11 @@ timeset = [];

if ((plb(bymonth) && !_.include(bymonth, ii.mmask[i])) ||
if ((plb(bymonth) && !contains(bymonth, ii.mmask[i])) ||
(plb(byweekno) && !ii.wnomask[i]) ||
(plb(byweekday) && !_.include(byweekday, ii.wdaymask[i])) ||
(plb(byweekday) && !contains(byweekday, ii.wdaymask[i])) ||
(plb(ii.nwdaymask) && !ii.nwdaymask[i]) ||
(byeaster !== null && !_.include(ii.eastermask, i)) ||
(byeaster !== null && !contains(ii.eastermask, i)) ||
(
(plb(bymonthday) || plb(bynmonthday)) &&
!_.include(bymonthday, ii.mdaymask[i]) &&
!_.include(bynmonthday, ii.nmdaymask[i])
!contains(bymonthday, ii.mdaymask[i]) &&
!contains(bynmonthday, ii.nmdaymask[i])
)

@@ -1124,4 +1135,4 @@ ||

i < ii.yearlen &&
!_.include(byyearday, i + 1) &&
!_.include(byyearday, -ii.yearlen + i)
!contains(byyearday, i + 1) &&
!contains(byyearday, -ii.yearlen + i)
)

@@ -1131,4 +1142,4 @@ ||

i >= ii.yearlen &&
!_.include(byyearday, i + 1 - ii.yearlen) &&
!_.include(byyearday, -ii.nextyearlen + i - ii.yearlen)
!contains(byyearday, i + 1 - ii.yearlen) &&
!contains(byyearday, -ii.nextyearlen + i - ii.yearlen)
)

@@ -1181,3 +1192,3 @@ )

// - compare the actual date instead?
if (!_.include(poslist, res)) {
if (!contains(poslist, res)) {
poslist.push(res);

@@ -1291,3 +1302,3 @@ }

}
if (!plb(byhour) || _.include(byhour, hour)) {
if (!plb(byhour) || contains(byhour, hour)) {
break;

@@ -1321,4 +1332,4 @@ }

}
if ((!plb(byhour) || _.include(byhour, hour)) &&
(!plb(byminute) || _.include(byminute, minute))) {
if ((!plb(byhour) || contains(byhour, hour)) &&
(!plb(byminute) || contains(byminute, minute))) {
break;

@@ -1359,5 +1370,5 @@ }

}
if ((!plb(byhour) || _.include(byhour, hour)) &&
(!plb(byminute) || _.include(byminute, minute)) &&
(!plb(bysecond) || _.include(bysecond, second)))
if ((!plb(byhour) || contains(byhour, hour)) &&
(!plb(byminute) || contains(byminute, minute)) &&
(!plb(bysecond) || contains(bysecond, second)))
{

@@ -1596,3 +1607,3 @@ break;

if (_.include(rr.options.byweekno, 1)) {
if (contains(rr.options.byweekno, 1)) {
// Check week number 1 of next year as well

@@ -1625,3 +1636,3 @@ // orig-TODO : Check -numweeks for next year.

var lnumweeks;
if (!_.include(rr.options.byweekno, -1)) {
if (!contains(rr.options.byweekno, -1)) {
var lyearweekday = dateutil.getWeekday(

@@ -1647,3 +1658,3 @@ new Date(year - 1, 0, 1));

}
if (_.include(rr.options.byweekno, lnumweeks)) {
if (contains(rr.options.byweekno, lnumweeks)) {
for (var i = 0; i < no1wkst; i++) {

@@ -1879,5 +1890,5 @@ this.wnomask[i] = 1;

var allowedMethods = ['all', 'between'];
if (!_.include(allowedMethods, method)) {
throw 'Invalid method "' + method
+ '". Only all and between works with iterator.'
if (!contains(allowedMethods, method)) {
throw new Error('Invalid method "' + method
+ '". Only all and between works with iterator.');
}

@@ -1884,0 +1895,0 @@ this.add = function(date) {

{
"name": "rrule",
"version": "2.0.1",
"version": "2.1.0",
"description": "JavaScript library for working with recurrence rules for calendar dates.",
"homepage": "http://jkbr.github.io/rrule/",
"homepage": "http://jakubroztocil.github.io/rrule/",
"keywords":[

@@ -17,7 +17,7 @@ "dates",

"type": "git",
"url": "git://github.com/jkbr/rrule.git"
"url": "git://github.com/jakubroztocil/rrule.git"
},
"dependencies": {
"underscore": ">= 1.3.3"
"scripts": {
"test": "echo Run tests in the browser at tests/index.html"
}
}

@@ -13,4 +13,2 @@ rrule.js

The only dependency is [Underscore.js](http://underscorejs.org/).
* * * * *

@@ -21,4 +19,4 @@

- [Demo app](http://jkbr.github.io/rrule/)
- [Test suite](http://jkbr.github.io/rrule/tests/index.html)
- [Demo app](http://jakubroztocil.github.io/rrule/)
- [Test suite](http://jakubroztocil.github.io/rrule/tests/index.html)

@@ -33,8 +31,7 @@

Alternatively, download
[rrule.js](https://raw.github.com/jkbr/rrule/master/lib/rrule.js) manually. If
[rrule.js](https://raw.github.com/jakubroztocil/rrule/master/lib/rrule.js) manually. If
you intend to use `RRule.prototype.toText()` or `RRule.fromText()`, you'll
also need [nlp.js](https://raw.github.com/jkbr/rrule/master/lib/nlp.js).
also need [nlp.js](https://raw.github.com/jakubroztocil/rrule/master/lib/nlp.js).
```html
<script src="underscore.js"></script>
<script src="rrule/lib/rrule.js"></script>

@@ -93,3 +90,3 @@

For more examples see
[tests/tests.js](https://github.com/jkbr/rrule/blob/master/tests/tests.js)
[tests/tests.js](https://github.com/jakubroztocil/rrule/blob/master/tests/tests.js)
and [python-dateutil](http://labix.org/python-dateutil/) documentation.

@@ -466,2 +463,5 @@

* 2.1.0
* Removed dependency on Underscore.js (thanks @gsf).
* Various small bugfixes and improvements.
* 2.0.1

@@ -487,3 +487,3 @@ * Added bower.json.

* 1.1.0 (2013-05-21)
* Added a [demo app](http://jkbr.github.io/rrule/).
* Added a [demo app](http://jakubroztocil.github.io/rrule/).
* Handle dates in `UNTIL` in `RRule.fromString`.

@@ -503,3 +503,3 @@ * Added support for RequireJS.

* [Jakub Roztocil](http://subtleapps.com/)
([@jkbrzt](http://twitter.com/jkbrzt))
([@jakubroztocil](http://twitter.com/jakubroztocil))
* Lars Schöning ([@lyschoening](http://twitter.com/lyschoening))

@@ -510,3 +510,3 @@

See [LICENCE](https://github.com/jkbr/rrule/blob/master/LICENCE) for
See [LICENCE](https://github.com/jakubroztocil/rrule/blob/master/LICENCE) for
more details.

@@ -34,7 +34,7 @@ // Generated by CoffeeScript 1.6.2

v = 'RRule.' + RRule.FREQUENCIES[v];
} else if (_.contains(["dtstart", "until"], k)) {
} else if (k === "dtstart" || k === "until") {
v = "new Date(" + [v.getFullYear(), v.getMonth(), v.getDate(), v.getHours(), v.getMinutes(), v.getSeconds()].join(', ') + ")";
} else if (k === "byweekday") {
if (v instanceof Array) {
v = _.map(v, function(wday) {
v = v.map(function(wday) {
var s;

@@ -135,4 +135,4 @@

});
$("input, select").on("keyup change", function() {
var $in, $section, d, dates, e, getDay, html, init, inputMethod, k, makeRule, max, options, rfc, rule, text, v, values,
$("input, select").on('keyup change', function() {
var $in, $section, date, dates, days, e, getDay, html, init, inputMethod, key, makeRule, max, options, rfc, rule, text, v, value, values,
_this = this;

@@ -159,36 +159,48 @@

options = {};
days = [RRule.MO, RRule.TU, RRule.WE, RRule.TH, RRule.FR, RRule.SA, RRule.SU];
getDay = function(i) {
return [RRule.MO, RRule.TU, RRule.WE, RRule.TH, RRule.FR, RRule.SA, RRule.SU][i];
return days[i];
};
for (k in values) {
v = values[k];
if (!v) {
for (key in values) {
value = values[key];
if (!value) {
continue;
}
if (_.contains(["dtstart", "until"], k)) {
d = new Date(Date.parse(v));
v = new Date(d.getTime() + (d.getTimezoneOffset() * 60 * 1000));
} else if (k === 'byweekday') {
if (v instanceof Array) {
v = _.map(v, getDay);
} else if (key === 'dtstart' || key === 'until') {
date = new Date(Date.parse(value));
value = new Date(date.getTime() + (date.getTimezoneOffset() * 60 * 1000));
} else if (key === 'byweekday') {
if (value instanceof Array) {
value = value.map(getDay);
} else {
v = getDay(v);
value = getDay(value);
}
} else if (/^by/.test(k)) {
if (!(v instanceof Array)) {
v = _.compact(v.split(/[,\s]+/));
} else if (/^by/.test(key)) {
if (!value instanceof Array) {
value = value.split(/[,\s]+/);
}
v = _.map(v, function(n) {
value = (function() {
var _i, _len, _results;
_results = [];
for (_i = 0, _len = value.length; _i < _len; _i++) {
v = value[_i];
if (v) {
_results.push(v);
}
}
return _results;
})();
value = value.map(function(n) {
return parseInt(n, 10);
});
} else {
v = parseInt(v, 10);
value = parseInt(value, 10);
}
if (k === 'wkst') {
v = getDay(v);
if (key === 'wkst') {
value = getDay(value);
}
if (k === 'interval' && v === 1) {
if (key === 'interval' && value === 1) {
continue;
}
options[k] = v;
options[key] = value;
}

@@ -195,0 +207,0 @@ makeRule = function() {

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is too big to display

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc