Comparing version 1.1.0 to 2.0.0
/*! | ||
* rrule.js - Library for working with recurrence rules for calendar dates. | ||
* v1.0.0-beta | ||
* https://github.com/jkbr/rrule | ||
@@ -51,3 +50,2 @@ * | ||
* Optional: | ||
* @param {Date} today - for formatting the UNTIL rule | ||
* @param {Function} gettext function | ||
@@ -57,11 +55,10 @@ * @param {Object} language definition | ||
*/ | ||
var ToText = function(rrule, today, gettext, language) { | ||
var ToText = function(rrule, gettext, language) { | ||
this.gettext = gettext || function(id) {return id}; | ||
this.language = language || ENGLISH; | ||
this.today = today; | ||
this.text = ''; | ||
this.rrule = rrule; | ||
this.freq = rrule.freq; | ||
this.freq = rrule.options.freq; | ||
this.options = rrule.options; | ||
@@ -146,3 +143,3 @@ this.origOptions = rrule.origOptions; | ||
if (!(rrule.freq in ToText.IMPLEMENTED)) { | ||
if (!(rrule.options.freq in ToText.IMPLEMENTED)) { | ||
return false; | ||
@@ -154,6 +151,6 @@ } | ||
_.each(rrule.origOptions, function(value, key){ | ||
if (key == 'dtstart' || key == 'wkst') { | ||
if (_.contains(['dtstart', 'wkst', 'freq'], key)) { | ||
return true; | ||
} | ||
if (!_.include(ToText.IMPLEMENTED[rrule.freq], key)) { | ||
if (!_.include(ToText.IMPLEMENTED[rrule.options.freq], key)) { | ||
canConvert = false; | ||
@@ -177,3 +174,3 @@ return false; | ||
/** | ||
* Perform the conversion. Only some some frequencies are supported. | ||
* Perform the conversion. Only some of the frequencies are supported. | ||
* If some of the rrule's options aren't supported, they'll | ||
@@ -187,3 +184,3 @@ * be omitted from the output an "(~ approximate)" will be appended. | ||
if (!(this.freq in ToText.IMPLEMENTED)) { | ||
if (!(this.options.freq in ToText.IMPLEMENTED)) { | ||
return gettext( | ||
@@ -195,3 +192,3 @@ 'RRule error: Unable to fully convert this rrule to text'); | ||
this[RRule.FREQUENCIES[this.freq]](); | ||
this[RRule.FREQUENCIES[this.options.freq]](); | ||
@@ -201,9 +198,5 @@ if (this.options.until) { | ||
var until = this.options.until; | ||
if (!this.today) { | ||
this.add(this.language.monthNames[until.getMonth()]) | ||
.add(until.getDate() + ',') | ||
.add(until.getFullYear()); | ||
} else { | ||
// TODO | ||
} | ||
this.add(this.language.monthNames[until.getMonth()]) | ||
.add(until.getDate() + ',') | ||
.add(until.getFullYear()); | ||
} else if (this.options.count) { | ||
@@ -558,4 +551,7 @@ this.add(gettext('for')) | ||
*/ | ||
var fromText = function(text, language) { | ||
return new RRule(parseText(text, language)) | ||
}; | ||
var fromText = function(text, dtstart, language) { | ||
var parseText = function(text, language) { | ||
@@ -568,12 +564,6 @@ var ttr = new Parser((language || ENGLISH).tokens); | ||
var freq, options = { | ||
'dtstart': dtstart | ||
}; | ||
var options = {}; | ||
try { | ||
S(); | ||
return new RRule(freq, options); | ||
} catch(e) { | ||
return null; | ||
} | ||
S(); | ||
return options; | ||
@@ -593,3 +583,3 @@ function S() { | ||
case 'day(s)': | ||
freq = RRule.DAILY; | ||
options.freq = RRule.DAILY; | ||
if (ttr.nextSymbol()) { | ||
@@ -604,3 +594,3 @@ ON(); | ||
case 'weekday(s)': | ||
freq = RRule.WEEKLY; | ||
options.freq = RRule.WEEKLY; | ||
options.byweekday = [ | ||
@@ -618,3 +608,3 @@ RRule.MO, | ||
case 'week(s)': | ||
freq = RRule.WEEKLY; | ||
options.freq = RRule.WEEKLY; | ||
if (ttr.nextSymbol()) { | ||
@@ -627,3 +617,3 @@ ON(); | ||
case 'month(s)': | ||
freq = RRule.MONTHLY; | ||
options.freq = RRule.MONTHLY; | ||
if (ttr.nextSymbol()) { | ||
@@ -636,3 +626,3 @@ ON(); | ||
case 'year(s)': | ||
freq = RRule.YEARLY; | ||
options.freq = RRule.YEARLY; | ||
if (ttr.nextSymbol()) { | ||
@@ -651,3 +641,3 @@ ON(); | ||
case 'sunday': | ||
freq = RRule.WEEKLY; | ||
options.freq = RRule.WEEKLY; | ||
options.byweekday = [RRule[ttr.symbol.substr(0, 2).toUpperCase()]]; | ||
@@ -688,3 +678,3 @@ | ||
case 'december': | ||
freq = RRule.YEARLY; | ||
options.freq = RRule.YEARLY; | ||
options.bymonth = [decodeM()]; | ||
@@ -741,3 +731,3 @@ | ||
} | ||
options.byweekday.push(RRule[wkd].clone(nth)); | ||
options.byweekday.push(RRule[wkd].nth(nth)); | ||
} else { | ||
@@ -1066,5 +1056,6 @@ if(!options.bymonthday) { | ||
fromText: fromText, | ||
parseText: parseText, | ||
isFullyConvertible: ToText.isFullyConvertible, | ||
toText: function(rrule, today, gettext, language) { | ||
return new ToText(rrule, today, gettext, language).toString(); | ||
toText: function(rrule, gettext, language) { | ||
return new ToText(rrule, gettext, language).toString(); | ||
} | ||
@@ -1071,0 +1062,0 @@ }; |
345
lib/rrule.js
/*! | ||
* rrule.js - Library for working with recurrence rules for calendar dates. | ||
* v1.0.0-beta | ||
* https://github.com/jkbr/rrule | ||
@@ -43,3 +42,3 @@ * | ||
return getnlp._nlp; | ||
} | ||
}; | ||
@@ -152,3 +151,4 @@ | ||
return month == 1 && dateutil.isLeapYear(date) | ||
? 29 : dateutil.MONTH_DAYS[month]; | ||
? 29 | ||
: dateutil.MONTH_DAYS[month]; | ||
}, | ||
@@ -344,2 +344,9 @@ | ||
var M365MASK = [].concat( | ||
repeat(1, 31), repeat(2, 28), repeat(3, 31), | ||
repeat(4, 30), repeat(5, 31), repeat(6, 30), | ||
repeat(7, 31), repeat(8, 31), repeat(9, 30), | ||
repeat(10, 31), repeat(11, 30), repeat(12, 31), | ||
repeat(1, 7) | ||
); | ||
var M366MASK = [].concat( | ||
@@ -352,9 +359,8 @@ repeat(1, 31), repeat(2, 29), repeat(3, 31), | ||
); | ||
var M365MASK = [].concat(M366MASK); | ||
var | ||
M28 = range(1, 29), | ||
M29 = range(1, 30), | ||
M30 = range(1, 31), | ||
M31 = range(1, 32); | ||
var MDAY366MASK = [].concat( | ||
@@ -367,8 +373,14 @@ M31, M29, M31, | ||
); | ||
var MDAY365MASK = [].concat(MDAY366MASK); | ||
var MDAY365MASK = [].concat( | ||
M31, M28, M31, | ||
M30, M31, M30, | ||
M31, M31, M30, | ||
M31, M30, M31, | ||
M31.slice(0, 7) | ||
); | ||
M28 = range(-28, 0); | ||
M29 = range(-29, 0); | ||
M30 = range(-30, 0); | ||
M31 = range(-31, 0); | ||
var NMDAY366MASK = [].concat( | ||
@@ -381,6 +393,12 @@ M31, M29, M31, | ||
); | ||
var NMDAY365MASK = [].concat(NMDAY366MASK); | ||
var NMDAY365MASK = [].concat( | ||
M31, M28, M31, | ||
M30, M31, M30, | ||
M31, M31, M30, | ||
M31, M30, M31, | ||
M31.slice(0, 7) | ||
); | ||
var M366RANGE = [0,31,60,91,121,152,182,213,244,274,305,335,366]; | ||
var M365RANGE = [0,31,59,90,120,151,181,212,243,273,304,334,365]; | ||
var M366RANGE = [0, 31, 60, 91, 121, 152, 182, 213, 244, 274, 305, 335, 366]; | ||
var M365RANGE = [0, 31, 59, 90, 120, 151, 181, 212, 243, 273, 304, 334, 365]; | ||
@@ -394,8 +412,3 @@ var WDAYMASK = (function() { | ||
M29 = M30 = M31 = null; | ||
M365MASK = M365MASK.slice(0, 58).concat(M365MASK.slice(59, M365MASK.length)); | ||
MDAY365MASK = MDAY365MASK.slice(0, 58).concat(MDAY365MASK.slice(59)); | ||
NMDAY365MASK = NMDAY365MASK.slice(0, 31).concat(NMDAY365MASK.slice(32)); | ||
//============================================================================= | ||
@@ -416,4 +429,4 @@ // Weekday | ||
// __call__ - Cannot call the object directly, do it through | ||
// e.g. RRule.TH.clone(-1) instead, | ||
clone: function(n) { | ||
// e.g. RRule.TH.nth(-1) instead, | ||
nth: function(n) { | ||
return this.n == n ? this : new Weekday(this.weekday, n); | ||
@@ -449,7 +462,7 @@ }, | ||
* | ||
* @param {String} freq - one of RRule.YEARLY, RRule.MONTHLY, ... | ||
* @param {Object?} options - see <http://labix.org/python-dateutil/#head-cf004ee9a75592797e076752b2a889c10f445418> | ||
* The only required option is `freq`, one of RRule.YEARLY, RRule.MONTHLY, ... | ||
* @constructor | ||
*/ | ||
var RRule = function(freq, options) { | ||
var RRule = function(options, noCache) { | ||
@@ -459,5 +472,6 @@ // RFC string | ||
options = options || {} | ||
var defaults = _.clone(RRule.DEFAULT_OPTIONS); | ||
options = options || {}; | ||
this._cache = { | ||
this._cache = noCache ? null : { | ||
all: false, | ||
@@ -469,22 +483,2 @@ before: [], | ||
var defaults = { | ||
cache: true, | ||
dtstart: null, | ||
interval: 1, | ||
wkst: 0, | ||
count: null, | ||
until: null, | ||
bysetpos: null, | ||
bymonth: null, | ||
bymonthday: null, | ||
byyearday: null, | ||
byweekno: null, | ||
byweekday: null, | ||
byhour: null, | ||
byminute: null, | ||
bysecond: null, | ||
// not implemented: | ||
byeaster: null | ||
}; | ||
var invalid = _(options) | ||
@@ -501,8 +495,10 @@ .chain() | ||
if (!RRule.FREQUENCIES[options.freq]) { | ||
throw 'Invalid frequency: ' + String(options.freq) | ||
} | ||
// used by toString() | ||
this.origOptions = _.clone(options); | ||
var opts; | ||
this.freq = freq; | ||
this.options = opts = _.extend(defaults, options); | ||
this.options = opts = _.extend({}, defaults, options); | ||
@@ -542,3 +538,3 @@ if (opts.byeaster !== null) { | ||
{ | ||
switch (this.freq) { | ||
switch (opts.freq) { | ||
case RRule.YEARLY: | ||
@@ -614,3 +610,3 @@ if (!opts.bymonth) { | ||
if (!opts.byweekday.n || this.freq > RRule.MONTHLY) { | ||
if (!opts.byweekday.n || opts.freq > RRule.MONTHLY) { | ||
opts.byweekday = [opts.byweekday.weekday]; | ||
@@ -634,3 +630,3 @@ opts.bynweekday = null; | ||
byweekday.push(wday); | ||
} else if (!wday.n || this.freq > RRule.MONTHLY) { | ||
} else if (!wday.n || opts.freq > RRule.MONTHLY) { | ||
byweekday.push(wday.weekday); | ||
@@ -647,3 +643,3 @@ } else { | ||
if (opts.byhour === null) { | ||
opts.byhour = (this.freq < RRule.HOURLY) | ||
opts.byhour = (opts.freq < RRule.HOURLY) | ||
? [opts.dtstart.getHours()] | ||
@@ -657,3 +653,3 @@ : null; | ||
if (opts.byminute === null) { | ||
opts.byminute = (this.freq < RRule.MINUTELY) | ||
opts.byminute = (opts.freq < RRule.MINUTELY) | ||
? [opts.dtstart.getMinutes()] | ||
@@ -667,3 +663,3 @@ : null; | ||
if (opts.bysecond === null) { | ||
opts.bysecond = (this.freq < RRule.SECONDLY) | ||
opts.bysecond = (opts.freq < RRule.SECONDLY) | ||
? [opts.dtstart.getSeconds()] | ||
@@ -675,3 +671,3 @@ : null; | ||
if (this.freq >= RRule.HOURLY) { | ||
if (opts.freq >= RRule.HOURLY) { | ||
this.timeset = null; | ||
@@ -722,7 +718,110 @@ } else { | ||
RRule.DEFAULT_OPTIONS = { | ||
freq: null, | ||
dtstart: null, | ||
interval: 1, | ||
wkst: RRule.MO, | ||
count: null, | ||
until: null, | ||
bysetpos: null, | ||
bymonth: null, | ||
bymonthday: null, | ||
byyearday: null, | ||
byweekno: null, | ||
byweekday: null, | ||
byhour: null, | ||
byminute: null, | ||
bysecond: null, | ||
// not implemented: | ||
byeaster: null | ||
}; | ||
RRule.fromText = function(text, dtstart, language) { | ||
return getnlp().fromText(text, dtstart, language) | ||
RRule.parseText = function(text, language) { | ||
return getnlp().parseText(text, language) | ||
}; | ||
RRule.fromText = function(text, language) { | ||
return getnlp().fromText(text, language) | ||
}; | ||
RRule.optionsToString = function(options) { | ||
var key, keys, value, strValues, pairs = []; | ||
keys = _.intersection(_.keys(RRule.DEFAULT_OPTIONS), _.keys(options)); | ||
for (var i = 0; i < keys.length; i++) { | ||
key = keys[i].toUpperCase(); | ||
value = options[keys[i]]; | ||
strValues = []; | ||
if (value === null || value instanceof Array && !value.length) { | ||
continue; | ||
} | ||
switch (key) { | ||
case 'FREQ': | ||
value = RRule.FREQUENCIES[options.freq]; | ||
break; | ||
case 'WKST': | ||
value = value.toString(); | ||
break; | ||
case 'BYWEEKDAY': | ||
/* | ||
NOTE: BYWEEKDAY is a special case. | ||
RRule() deconstructs the rule.options.byweekday array | ||
into an array of Weekday arguments. | ||
On the other hand, rule.origOptions is an array of Weekdays. | ||
We need to handle both cases here. | ||
It might be worth change RRule to keep the Weekdays. | ||
Also, BYWEEKDAY (used by RRule) vs. BYDAY (RFC) | ||
*/ | ||
key = 'BYDAY'; | ||
if (!(value instanceof Array)) { | ||
value = [value]; | ||
} | ||
for (var wday, j = 0; j < value.length; j++) { | ||
wday = value[j]; | ||
if (wday instanceof Weekday) { | ||
// good | ||
} else if (wday instanceof Array) { | ||
wday = new Weekday(wday[0], wday[1]); | ||
} else { | ||
wday = new Weekday(wday); | ||
} | ||
strValues[j] = wday.toString(); | ||
} | ||
value = strValues; | ||
break; | ||
case'DTSTART': | ||
case'UNTIL': | ||
value = dateutil.timeToUntilString(value); | ||
break; | ||
default: | ||
if (value instanceof Array) { | ||
for (var j = 0; j < value.length; j++) { | ||
strValues[j] = String(value[j]); | ||
} | ||
value = strValues; | ||
} else { | ||
value = String(value); | ||
} | ||
} | ||
pairs.push([key, value]); | ||
} | ||
var strings = []; | ||
for (var i = 0; i < pairs.length; i++) { | ||
var attr = pairs[i]; | ||
strings.push(attr[0] + '=' + attr[1].toString()); | ||
} | ||
return strings.join(';'); | ||
}; | ||
RRule.prototype = { | ||
@@ -828,88 +927,3 @@ | ||
toString: function() { | ||
var attrs = [], key, keys, value, | ||
origValue, currentValue, strValues; | ||
if (this._string) { | ||
return this._string; | ||
} | ||
keys = [ | ||
'byhour', 'byminute', 'bymonth', | ||
'bymonthday', 'bysecond', 'bysetpos', | ||
'byweekday', 'byweekno', 'byyearday', | ||
'count', 'interval', 'until', 'wkst' | ||
]; | ||
attrs.push(['FREQ', RRule.FREQUENCIES[this.freq]]); | ||
for (var i = 0; i < keys.length; i++) { | ||
key = keys[i]; | ||
// Only attributes specified in the options argument | ||
// passed to the constructor will be included in the string | ||
// representation | ||
if (typeof this.origOptions[key] == 'undefined') { | ||
continue; | ||
} | ||
// Do not modify the currentValue array, use this instead | ||
// to store string values | ||
strValues = []; | ||
// Some values are taken from the original options array | ||
// (this.origOptions), and some from the modified version | ||
// (this.options). | ||
currentValue = this.options[key]; | ||
origValue = this.origOptions[key]; | ||
key = key.toUpperCase(); | ||
switch (key) { | ||
case 'WKST': | ||
value = new Weekday(currentValue).toString(); | ||
break; | ||
case 'BYWEEKDAY': | ||
key = 'BYDAY'; | ||
// XXX: always use origValue, this won't work as expected | ||
// when byweekday contains +n and also -n | ||
value = (currentValue === null) | ||
? this.options.bynweekday | ||
: currentValue; | ||
for (var wday, j = 0; j < value.length; j++) { | ||
wday = value[j]; | ||
if (wday instanceof Array) { | ||
wday = new Weekday(wday[0], wday[1]); | ||
} else { | ||
wday = new Weekday(wday); | ||
} | ||
strValues[j] = wday.toString(); | ||
} | ||
value = strValues; | ||
break; | ||
case'UNTIL': | ||
value = dateutil.timeToUntilString(currentValue); | ||
break; | ||
default: | ||
if (origValue instanceof Array) { | ||
for (var j = 0; j < origValue.length; j++) { | ||
strValues[j] = String(origValue[j]); | ||
} | ||
value = strValues; | ||
} else { | ||
value = String(origValue); | ||
} | ||
} | ||
attrs.push([key, value]); | ||
} | ||
var strings = []; | ||
for (var i = 0; i < attrs.length; i++) { | ||
var attr = attrs[i]; | ||
strings.push(attr[0] + '=' + attr[1].toString()); | ||
} | ||
this._string = strings.join(';'); | ||
return this._string; | ||
return RRule.optionsToString(this.origOptions); | ||
}, | ||
@@ -921,4 +935,4 @@ | ||
*/ | ||
toText: function(today, gettext, language) { | ||
return getnlp().toText(this, today, gettext, language); | ||
toText: function(gettext, language) { | ||
return getnlp().toText(this, gettext, language); | ||
}, | ||
@@ -937,3 +951,3 @@ | ||
if (!this.options.cache) return; | ||
if (!this._cache) return; | ||
@@ -964,3 +978,3 @@ if (value) { | ||
if (!this.options.cache) { | ||
if (!this._cache) { | ||
return false; | ||
@@ -1015,3 +1029,3 @@ } | ||
clone: function() { | ||
return new RRule(this.freq, this.origOptions); | ||
return new RRule(this.origOptions); | ||
}, | ||
@@ -1040,3 +1054,3 @@ | ||
var | ||
freq = this.freq, | ||
freq = this.options.freq, | ||
interval = this.options.interval, | ||
@@ -1389,13 +1403,12 @@ wkst = this.options.wkst, | ||
RRule.fromString = function(string, dtstart, options) { | ||
string = string.replace(/^\s+|\s+$/, ''); | ||
if (!string.length) { | ||
RRule.parseString = function(rfcString) { | ||
rfcString = rfcString.replace(/^\s+|\s+$/, ''); | ||
if (!rfcString.length) { | ||
return null; | ||
} | ||
console.log (string) | ||
var i, j, key, value, freq, attr, | ||
attrs = string.split(';'), | ||
options = (options == undefined ? {} : options); | ||
var i, j, key, value, attr, | ||
attrs = rfcString.split(';'), | ||
options = {}; | ||
@@ -1408,6 +1421,6 @@ for (i = 0; i < attrs.length; i++) { | ||
case 'FREQ': | ||
freq = RRule[value]; | ||
options.freq = RRule[value]; | ||
break; | ||
case 'WKST': | ||
options.wkst = RRule[value].weekday; | ||
options.wkst = RRule[value]; | ||
break; | ||
@@ -1454,2 +1467,5 @@ case 'COUNT': | ||
break; | ||
case 'DTSTART': | ||
options.dtstart = dateutil.untilStringToDate(value); | ||
break; | ||
case 'UNTIL': | ||
@@ -1462,8 +1478,11 @@ options.until = dateutil.untilStringToDate(value); | ||
} | ||
return options; | ||
}; | ||
options.dtstart = dtstart; | ||
return new RRule(freq, options); | ||
RRule.fromString = function(string) { | ||
return new RRule(RRule.parseString(string)); | ||
}; | ||
//============================================================================= | ||
@@ -1627,3 +1646,3 @@ // Iterinfo | ||
var ranges = []; | ||
if (rr.freq == RRule.YEARLY) { | ||
if (rr.options.freq == RRule.YEARLY) { | ||
if (plb(rr.options.bymonth)) { | ||
@@ -1637,3 +1656,3 @@ for (j = 0; j < rr.options.bymonth.length; j++) { | ||
} | ||
} else if (rr.freq == RRule.MONTHLY) { | ||
} else if (rr.options.freq == RRule.MONTHLY) { | ||
ranges = [this.mrange.slice(month - 1, month + 1)]; | ||
@@ -1842,3 +1861,3 @@ } | ||
/** | ||
* IterResult subclass that calls a callback funciton on each add, | ||
* IterResult subclass that calls a callback function on each add, | ||
* and stops iterating when the callback returns false. | ||
@@ -1853,4 +1872,8 @@ */ | ||
this.add = function(date) { | ||
this._result.push(date); | ||
return iterator(date, this._result.length) !== false; | ||
if (iterator(date, this._result.length)) { | ||
this._result.push(date); | ||
return true; | ||
} | ||
return false; | ||
}; | ||
@@ -1857,0 +1880,0 @@ |
{ | ||
"name": "rrule", | ||
"version": "1.1.0", | ||
"version": "2.0.0", | ||
"description": "JavaScript library for working with recurrence rules for calendar dates.", | ||
@@ -5,0 +5,0 @@ "homepage": "https://github.com/jkbr/rrule", |
@@ -30,10 +30,19 @@ // Generated by CoffeeScript 1.6.2 | ||
v = options[k]; | ||
if (_.contains(["dtstart", "until"], k)) { | ||
console.log(k, v); | ||
if (v === null) { | ||
v = 'null'; | ||
} else if (k === 'freq') { | ||
v = 'RRule.' + RRule.FREQUENCIES[v]; | ||
} else if (_.contains(["dtstart", "until"], k)) { | ||
v = "new Date(" + [v.getFullYear(), v.getMonth(), v.getDate(), v.getHours(), v.getMinutes(), v.getSeconds()].join(', ') + ")"; | ||
} else if (k === "byweekday") { | ||
console.log('BBBB', v); | ||
if (v instanceof Array) { | ||
v = _.map(v, function(d) { | ||
return days[d.weekday]; | ||
v = _.map(v, function(wday) { | ||
var s; | ||
console.log('wday', wday); | ||
s = days[wday.weekday]; | ||
if (wday.n) { | ||
s += '.nth(' + wday.n + ')'; | ||
} | ||
return s; | ||
}); | ||
@@ -100,3 +109,3 @@ } else { | ||
$(function() { | ||
var $tabs, activateTab; | ||
var $tabs, activateTab, processHash; | ||
@@ -128,3 +137,3 @@ $tabs = $("#tabs"); | ||
$("input, select").on("keyup change", function() { | ||
var $in, $section, d, dates, e, freq, getDay, html, init, inputMethod, k, makeRule, max, options, rule, v, values, | ||
var $in, $section, d, dates, e, getDay, html, init, inputMethod, k, makeRule, max, options, rfc, rule, text, v, values, | ||
_this = this; | ||
@@ -186,13 +195,12 @@ | ||
} | ||
freq = options.freq; | ||
delete options.freq; | ||
makeRule = function() { | ||
return new RRule(freq, options); | ||
return new RRule(options); | ||
}; | ||
init = "new RRule(RRule." + RRule.FREQUENCIES[freq] + ", " + getOptionsCode(options) + ")"; | ||
init = "new RRule(" + getOptionsCode(options) + ")"; | ||
console.log(options); | ||
} | ||
$("#init").html(init); | ||
$("#rfc-output").html(""); | ||
$("#text-output").html(""); | ||
$("#rfc-output a").html(""); | ||
$("#text-output a").html(""); | ||
$("#options-output").html(""); | ||
$("#dates").html(""); | ||
@@ -203,25 +211,47 @@ try { | ||
e = _error; | ||
} | ||
if (!rule) { | ||
$("#init").append($('<pre class="error"/>').text('=> ' + String(e || null))); | ||
return; | ||
} | ||
if (rule) { | ||
$("#rfc-output").text(rule.toString()); | ||
$("#text-output").text(rule.toText()); | ||
max = 500; | ||
dates = rule.all(function(date, i) { | ||
if (!rule.options.count && i === max) { | ||
return false; | ||
} | ||
}); | ||
html = makeRows(dates); | ||
if (!rule.options.count) { | ||
html += "<tr><td colspan='7'><em>Showing first " + max + " dates, set\n<code>count</code> to see more.</em></td></tr>"; | ||
rfc = rule.toString(); | ||
text = rule.toText(); | ||
$("#rfc-output a").text(rfc).attr('href', "#/rfc/" + rfc); | ||
$("#text-output a").text(text).attr('href', "#/text/" + text); | ||
$("#options-output").text(getOptionsCode(rule.origOptions)); | ||
if (inputMethod === 'options') { | ||
$("#options-output").parents('tr').hide(); | ||
} else { | ||
$("#options-output").parents('tr').show(); | ||
} | ||
max = 500; | ||
dates = rule.all(function(date, i) { | ||
if (!rule.options.count && i === max) { | ||
return false; | ||
} | ||
return $("#dates").html(html); | ||
return true; | ||
}); | ||
html = makeRows(dates); | ||
if (!rule.options.count) { | ||
html += "<tr><td colspan='7'><em>Showing first " + max + " dates, set\n<code>count</code> to see more.</em></td></tr>"; | ||
} | ||
return $("#dates").html(html); | ||
}); | ||
return activateTab($tabs.find("a:first")); | ||
activateTab($tabs.find("a:first")); | ||
processHash = function() { | ||
var arg, hash, match, method; | ||
hash = location.hash.substring(1); | ||
if (hash) { | ||
match = /^\/(rfc|text)\/(.+)$/.exec(hash); | ||
if (match) { | ||
method = match[1]; | ||
arg = match[2]; | ||
activateTab($("a[href=#" + method + "-input]")); | ||
return $("#" + method + "-input input:first").val(arg).change(); | ||
} | ||
} | ||
}; | ||
processHash(); | ||
return $(window).on('hashchange', processHash); | ||
}); | ||
}).call(this); |
@@ -50,4 +50,4 @@ | ||
for (var exp, act, i = 0; i < expected.length; i++) { | ||
exp = actual[i]; | ||
act = expected[i]; | ||
act = actual[i]; | ||
exp = expected[i]; | ||
equal(exp instanceof Date ? exp.toString() : exp, | ||
@@ -60,3 +60,3 @@ act.toString(), msg + (i + 1) + '/' + expected.length); | ||
var testRecurring = function(msg, rruleOrObj, expectedDates) { | ||
console.log(msg) | ||
var rrule, method, args; | ||
@@ -63,0 +63,0 @@ |
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 not supported yet
Sorry, the diff of this file is too big to display
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
666189
16525
497
0