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

moment-recur

Package Overview
Dependencies
Maintainers
1
Versions
5
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

moment-recur - npm Package Compare versions

Comparing version 1.0.4 to 1.0.5

64

moment-recur.js

@@ -78,2 +78,3 @@ (function (root, factory) {

"weeksOfMonth": "monthWeek",
"weeksOfMonthByDay": "monthWeekByDay",
"weeksOfYear": "weeks",

@@ -85,7 +86,8 @@ "monthsOfYear": "months"

var ranges = {
"daysOfMonth" : { low: 1, high: 31 },
"daysOfWeek" : { low: 0, high: 6 },
"weeksOfMonth" : { low: 0, high: 4 },
"weeksOfYear" : { low: 0, high: 52 },
"monthsOfYear" : { low: 0, high: 11 }
"daysOfMonth" : { low: 1, high: 31 },
"daysOfWeek" : { low: 0, high: 6 },
"weeksOfMonth" : { low: 0, high: 4 },
"weeksOfMonthByDay" : { low: 0, high: 4 },
"weeksOfYear" : { low: 0, high: 52 },
"monthsOfYear" : { low: 0, high: 11 }
};

@@ -159,3 +161,3 @@

}
// match on end of month days

@@ -192,2 +194,3 @@ if ( unitType === 'date' && unit == date.add(1, 'months').date(0).format('D') && unit < 31) {

"weeksOfMonth": "calendar",
"weeksOfMonthByDay": "calendar",
"weeksOfYear": "calendar",

@@ -206,2 +209,3 @@ "monthsOfYear": "calendar"

"weeksOfMonth": "weekOfMonth",
"weeksOfMonthByDay": "weekOfMonthByDay",
"weeksOfYear": "weekOfYear",

@@ -253,2 +257,6 @@ "monthsOfYear": "monthOfYear"

if (rule.measure === 'weeksOfMonthByDay' && !this.hasRule('daysOfWeek')) {
throw Error("weeksOfMonthByDay must be combined with daysOfWeek");
}
// Remove existing rule based on measure

@@ -394,2 +402,5 @@ for (var i = 0; i < this.rules.length; i++) {

case "weekOfMonthByDay":
return "weeksOfMonthByDay";
case "weekOfYear":

@@ -461,3 +472,3 @@ return "weeksOfYear";

this.exceptions = [];
for(i = 0; i < exceptions.length; i++) {
for(var i = 0; i < exceptions.length; i++) {
this.except(exceptions[i]);

@@ -601,2 +612,13 @@ }

// Checks if a rule has been set on the chain
Recur.prototype.hasRule = function(measure) {
var i, len;
for (i = 0, len = this.rules.length; i < len; i++) {
if (this.rules[i].measure === pluralize(measure)) {
return true;
}
}
return false;
};
// Attempts to match a date to the rules

@@ -702,2 +724,27 @@ Recur.prototype.matches = function(dateToMatch, ignoreStartEnd) {

// Plugin for calculating the occurrence of the day of the week in the month.
// Similar to `moment().monthWeek()`, the return value is zero-indexed.
// A return value of 2 means the date is the 3rd occurence of that day
// of the week in the month.
moment.fn.monthWeekByDay = function(date) {
var day, week0, day0, diff;
// date obj
day = this.clone();
// First day of the first week of the month
week0 = this.clone().startOf("month").startOf("week");
// First day of week
day0 = this.clone().startOf("week");
diff = day0.diff(week0, "weeks");
if (day.subtract(diff, "weeks").month() === this.clone().month()) {
return diff;
}
return diff - 1;
};
// Plugin for removing all time information from a given date

@@ -708,8 +755,7 @@ moment.fn.dateOnly = function() {

} else {
return this.hours(0).minutes(0).seconds(0).milliseconds(0).add('minute',this.utcOffset()).utcOffset(0);
return this.hours(0).minutes(0).seconds(0).milliseconds(0).add(this.utcOffset(), "minute").utcOffset(0);
}
};
return moment;
}));

2

moment-recur.min.js

@@ -1,1 +0,1 @@

!function(a,b){"object"==typeof exports?module.exports=b(require("moment")):"function"==typeof define&&define.amd?define("moment-recur",["moment"],b):a.moment=b(a.moment)}(this,function(a){var b;if(b="undefined"!=typeof module&&null!==module&&null!=module.exports,"undefined"==typeof a)throw Error("Can't find moment");var c=function(){function a(a,b){for(var c in a)if(a.hasOwnProperty(c)&&parseInt(c,10)<=0)throw Error("Intervals must be greater than zero");return{measure:b.toLowerCase(),units:a}}function b(a,b,c,d){var e=null;e=d.isBefore(c)?c.diff(d,a,!0):d.diff(c,a,!0),"days"==a&&(e=parseInt(e));for(var f in b)if(b.hasOwnProperty(f)&&(f=parseInt(f,10),e%f===0))return!0;return!1}return{create:a,match:b}}(),d=function(){function b(a,b,c){c.forEach(function(c){if(a>c||c>b)throw Error("Value should be in range "+a+" to "+b)})}function c(b,c){var d,e,f,g={};for(d in b)b.hasOwnProperty(d)&&(e=parseInt(d,10),isNaN(e)&&(e=d),f=a().set(c,e).get(c),g[f]=b[d]);return g}function d(a,d){var e=[];"daysOfWeek"===d&&(a=c(a,"days")),"monthsOfYear"===d&&(a=c(a,"months"));for(var f in a)hasOwnProperty.call(a,f)&&e.push(f);return b(g[d].low,g[d].high,e),{measure:d,units:a}}function e(a,b,c){var d=f[a],e=c[d]();if(b[e])return!0;if("date"===d&&e==c.add(1,"months").date(0).format("D")&&31>e)for(;31>=e;){if(b[e])return!0;e++}return!1}var f={daysOfMonth:"date",daysOfWeek:"day",weeksOfMonth:"monthWeek",weeksOfYear:"weeks",monthsOfYear:"months"},g={daysOfMonth:{low:1,high:31},daysOfWeek:{low:0,high:6},weeksOfMonth:{low:0,high:4},weeksOfYear:{low:0,high:52},monthsOfYear:{low:0,high:11}};return{create:d,match:e}}(),e=function(){function b(){var a,b=m[this.measure];if(!(this instanceof o))throw Error("Private method trigger() was called directly or not called as instance of Recur!");if("undefined"==typeof this.units||null===this.units||!this.measure)return this;if("calendar"!==b&&"interval"!==b)throw Error("Invlid measure provided: "+this.measure);if("interval"===b){if(!this.start)throw Error("Must have a start date set to set an interval!");a=c.create(this.units,this.measure)}"calendar"===b&&(a=d.create(this.units,this.measure)),this.units=null,this.measure=null;for(var e=0;e<this.rules.length;e++)this.rules[e].measure===a.measure&&this.rules.splice(e,1);return this.rules.push(a),this}function e(a,b,c){var d,e,f=[];if(!(this instanceof o))throw Error("Private method trigger() was called directly or not called as instance of Recur!");if(!this.start&&!this.from)throw Error("Cannot get occurances without start or from date.");if("all"===c&&!this.end)throw Error("Cannot get all occurances without an end date.");if(this.end&&this.start>this.end)throw Error("Start date cannot be later than end date.");if("all"!==c&&!(a>0))return f;for(d=(this.from||this.start).clone(),"all"===c&&this.matches(d,!1)&&(e=b?d.format(b):d.clone(),f.push(e));f.length<(null===a?f.length+1:a)&&("next"===c||"all"===c?d.add(1,"day"):d.subtract(1,"day"),this.matches(d,"all"===c?!1:!0)&&(e=b?d.format(b):d.clone(),f.push(e)),!("all"===c&&d>=this.end)););return f}function f(a,b,c){return a&&c.isBefore(a)?!1:b&&c.isAfter(b)?!1:!0}function g(a){var b={};if("[object Array]"==Object.prototype.toString.call(a))a.forEach(function(a){b[a]=!0});else if(a===Object(a))b=a;else{if("[object Number]"!=Object.prototype.toString.call(a)&&"[object String]"!=Object.prototype.toString.call(a))throw Error("Provide an array, object, string or number when passing units!");b[a]=!0}return b}function h(b,c){for(var d=0,e=b.length;e>d;d++)if(a(b[d]).isSame(c))return!0;return!1}function j(a){switch(a){case"day":return"days";case"week":return"weeks";case"month":return"months";case"year":return"years";case"dayOfWeek":return"daysOfWeek";case"dayOfMonth":return"daysOfMonth";case"weekOfMonth":return"weeksOfMonth";case"weekOfYear":return"weeksOfYear";case"monthOfYear":return"monthsOfYear";default:return a}}function k(a,b,e){var f,g,h,i;for(f=0,g=a.length;g>f;f++)if(h=a[f],i=m[h.measure],"interval"===i){if(!c.match(h.measure,h.units,e,b))return!1}else{if("calendar"!==i)return!1;if(!d.match(h.measure,h.units,b))return!1}return!0}function l(a){return function(b){return this.every.call(this,b,a),this}}var m={days:"interval",weeks:"interval",months:"interval",years:"interval",daysOfWeek:"calendar",daysOfMonth:"calendar",weeksOfMonth:"calendar",weeksOfYear:"calendar",monthsOfYear:"calendar"},n={days:"day",weeks:"week",months:"month",years:"year",daysOfWeek:"dayOfWeek",daysOfMonth:"dayOfMonth",weeksOfMonth:"weekOfMonth",weeksOfYear:"weekOfYear",monthsOfYear:"monthOfYear"},o=function(b){b.start&&(this.start=a(b.start).dateOnly()),b.end&&(this.end=a(b.end).dateOnly()),this.rules=b.rules||[];var c=b.exceptions||[];for(this.exceptions=[],i=0;i<c.length;i++)this.except(c[i]);return this.units=null,this.measure=null,this.from=null,this};o.prototype.startDate=function(b){return null===b?(this.start=null,this):b?(this.start=a(b).dateOnly(),this):this.start},o.prototype.endDate=function(b){return null===b?(this.end=null,this):b?(this.end=a(b).dateOnly(),this):this.end},o.prototype.fromDate=function(b){return null===b?(this.from=null,this):b?(this.from=a(b).dateOnly(),this):this.from},o.prototype.save=function(){var b={};this.start&&a(this.start).isValid()&&(b.start=this.start.format("L")),this.end&&a(this.end).isValid()&&(b.end=this.end.format("L")),b.exceptions=[];for(var c=0,d=this.exceptions.length;d>c;c++)b.exceptions.push(this.exceptions[c].format("L"));return b.rules=this.rules,b},o.prototype.repeats=function(){return this.rules.length>0?!0:!1},o.prototype.every=function(a,c){return"undefined"!=typeof a&&null!==a&&(this.units=g(a)),"undefined"!=typeof c&&null!==c&&(this.measure=j(c)),b.call(this)},o.prototype.except=function(b){return b=a(b).dateOnly(),this.exceptions.push(b),this},o.prototype.forget=function(b){var c,d,e=a(b);if(e.isValid()){for(e=e.dateOnly(),c=0,d=this.exceptions.length;d>c;c++)if(e.isSame(this.exceptions[c]))return this.exceptions.splice(c,1),this;return this}for(c=0,d=this.rules.length;d>c;c++)this.rules[c].measure===j(b)&&this.rules.splice(c,1)},o.prototype.matches=function(b,c){var d=a(b).dateOnly();if(!d.isValid())throw Error("Invalid date supplied to match method: "+b);return c||f(this.start,this.end,d)?h(this.exceptions,d)?!1:k(this.rules,d,this.start)?!0:!1:!1},o.prototype.next=function(a,b){return e.call(this,a,b,"next")},o.prototype.previous=function(a,b){return e.call(this,a,b,"previous")},o.prototype.all=function(a){return e.call(this,null,a,"all")};for(var p in n)m.hasOwnProperty(p)&&(o.prototype[p]=o.prototype[n[p]]=l(p));return o}();return a.recur=function(b,c){return new e(b!==Object(b)||a.isMoment(b)?{start:b,end:c}:b)},a.fn.recur=function(b,c){return b!==Object(b)||a.isMoment(b)?(c||(c=b,b=void 0),b||(b=this),new e({start:b,end:c,moment:this})):("undefined"==typeof b.start&&(b.start=this),new e(b))},a.fn.monthWeek=function(){var a=this.clone().startOf("month").startOf("week"),b=this.clone().startOf("week");return b.diff(a,"weeks")},a.fn.dateOnly=function(){return this.tz&&"function"==typeof a.tz?a.tz(this.format("YYYY/MM/DD"),"UTC"):this.hours(0).minutes(0).seconds(0).milliseconds(0).add("minute",this.utcOffset()).utcOffset(0)},a});
!function(a,b){"object"==typeof exports?module.exports=b(require("moment")):"function"==typeof define&&define.amd?define("moment-recur",["moment"],b):a.moment=b(a.moment)}(this,function(a){var b;if(b="undefined"!=typeof module&&null!==module&&null!=module.exports,"undefined"==typeof a)throw Error("Can't find moment");var c=function(){function a(a,b){for(var c in a)if(a.hasOwnProperty(c)&&parseInt(c,10)<=0)throw Error("Intervals must be greater than zero");return{measure:b.toLowerCase(),units:a}}function b(a,b,c,d){var e=null;e=d.isBefore(c)?c.diff(d,a,!0):d.diff(c,a,!0),"days"==a&&(e=parseInt(e));for(var f in b)if(b.hasOwnProperty(f)&&(f=parseInt(f,10),e%f===0))return!0;return!1}return{create:a,match:b}}(),d=function(){function b(a,b,c){c.forEach(function(c){if(a>c||c>b)throw Error("Value should be in range "+a+" to "+b)})}function c(b,c){var d,e,f,g={};for(d in b)b.hasOwnProperty(d)&&(e=parseInt(d,10),isNaN(e)&&(e=d),f=a().set(c,e).get(c),g[f]=b[d]);return g}function d(a,d){var e=[];"daysOfWeek"===d&&(a=c(a,"days")),"monthsOfYear"===d&&(a=c(a,"months"));for(var f in a)hasOwnProperty.call(a,f)&&e.push(f);return b(g[d].low,g[d].high,e),{measure:d,units:a}}function e(a,b,c){var d=f[a],e=c[d]();if(b[e])return!0;if("date"===d&&e==c.add(1,"months").date(0).format("D")&&31>e)for(;31>=e;){if(b[e])return!0;e++}return!1}var f={daysOfMonth:"date",daysOfWeek:"day",weeksOfMonth:"monthWeek",weeksOfMonthByDay:"monthWeekByDay",weeksOfYear:"weeks",monthsOfYear:"months"},g={daysOfMonth:{low:1,high:31},daysOfWeek:{low:0,high:6},weeksOfMonth:{low:0,high:4},weeksOfMonthByDay:{low:0,high:4},weeksOfYear:{low:0,high:52},monthsOfYear:{low:0,high:11}};return{create:d,match:e}}(),e=function(){function b(){var a,b=l[this.measure];if(!(this instanceof n))throw Error("Private method trigger() was called directly or not called as instance of Recur!");if("undefined"==typeof this.units||null===this.units||!this.measure)return this;if("calendar"!==b&&"interval"!==b)throw Error("Invlid measure provided: "+this.measure);if("interval"===b){if(!this.start)throw Error("Must have a start date set to set an interval!");a=c.create(this.units,this.measure)}if("calendar"===b&&(a=d.create(this.units,this.measure)),this.units=null,this.measure=null,"weeksOfMonthByDay"===a.measure&&!this.hasRule("daysOfWeek"))throw Error("weeksOfMonthByDay must be combined with daysOfWeek");for(var e=0;e<this.rules.length;e++)this.rules[e].measure===a.measure&&this.rules.splice(e,1);return this.rules.push(a),this}function e(a,b,c){var d,e,f=[];if(!(this instanceof n))throw Error("Private method trigger() was called directly or not called as instance of Recur!");if(!this.start&&!this.from)throw Error("Cannot get occurances without start or from date.");if("all"===c&&!this.end)throw Error("Cannot get all occurances without an end date.");if(this.end&&this.start>this.end)throw Error("Start date cannot be later than end date.");if("all"!==c&&!(a>0))return f;for(d=(this.from||this.start).clone(),"all"===c&&this.matches(d,!1)&&(e=b?d.format(b):d.clone(),f.push(e));f.length<(null===a?f.length+1:a)&&("next"===c||"all"===c?d.add(1,"day"):d.subtract(1,"day"),this.matches(d,"all"===c?!1:!0)&&(e=b?d.format(b):d.clone(),f.push(e)),!("all"===c&&d>=this.end)););return f}function f(a,b,c){return a&&c.isBefore(a)?!1:b&&c.isAfter(b)?!1:!0}function g(a){var b={};if("[object Array]"==Object.prototype.toString.call(a))a.forEach(function(a){b[a]=!0});else if(a===Object(a))b=a;else{if("[object Number]"!=Object.prototype.toString.call(a)&&"[object String]"!=Object.prototype.toString.call(a))throw Error("Provide an array, object, string or number when passing units!");b[a]=!0}return b}function h(b,c){for(var d=0,e=b.length;e>d;d++)if(a(b[d]).isSame(c))return!0;return!1}function i(a){switch(a){case"day":return"days";case"week":return"weeks";case"month":return"months";case"year":return"years";case"dayOfWeek":return"daysOfWeek";case"dayOfMonth":return"daysOfMonth";case"weekOfMonth":return"weeksOfMonth";case"weekOfMonthByDay":return"weeksOfMonthByDay";case"weekOfYear":return"weeksOfYear";case"monthOfYear":return"monthsOfYear";default:return a}}function j(a,b,e){var f,g,h,i;for(f=0,g=a.length;g>f;f++)if(h=a[f],i=l[h.measure],"interval"===i){if(!c.match(h.measure,h.units,e,b))return!1}else{if("calendar"!==i)return!1;if(!d.match(h.measure,h.units,b))return!1}return!0}function k(a){return function(b){return this.every.call(this,b,a),this}}var l={days:"interval",weeks:"interval",months:"interval",years:"interval",daysOfWeek:"calendar",daysOfMonth:"calendar",weeksOfMonth:"calendar",weeksOfMonthByDay:"calendar",weeksOfYear:"calendar",monthsOfYear:"calendar"},m={days:"day",weeks:"week",months:"month",years:"year",daysOfWeek:"dayOfWeek",daysOfMonth:"dayOfMonth",weeksOfMonth:"weekOfMonth",weeksOfMonthByDay:"weekOfMonthByDay",weeksOfYear:"weekOfYear",monthsOfYear:"monthOfYear"},n=function(b){b.start&&(this.start=a(b.start).dateOnly()),b.end&&(this.end=a(b.end).dateOnly()),this.rules=b.rules||[];var c=b.exceptions||[];this.exceptions=[];for(var d=0;d<c.length;d++)this.except(c[d]);return this.units=null,this.measure=null,this.from=null,this};n.prototype.startDate=function(b){return null===b?(this.start=null,this):b?(this.start=a(b).dateOnly(),this):this.start},n.prototype.endDate=function(b){return null===b?(this.end=null,this):b?(this.end=a(b).dateOnly(),this):this.end},n.prototype.fromDate=function(b){return null===b?(this.from=null,this):b?(this.from=a(b).dateOnly(),this):this.from},n.prototype.save=function(){var b={};this.start&&a(this.start).isValid()&&(b.start=this.start.format("L")),this.end&&a(this.end).isValid()&&(b.end=this.end.format("L")),b.exceptions=[];for(var c=0,d=this.exceptions.length;d>c;c++)b.exceptions.push(this.exceptions[c].format("L"));return b.rules=this.rules,b},n.prototype.repeats=function(){return this.rules.length>0?!0:!1},n.prototype.every=function(a,c){return"undefined"!=typeof a&&null!==a&&(this.units=g(a)),"undefined"!=typeof c&&null!==c&&(this.measure=i(c)),b.call(this)},n.prototype.except=function(b){return b=a(b).dateOnly(),this.exceptions.push(b),this},n.prototype.forget=function(b){var c,d,e=a(b);if(e.isValid()){for(e=e.dateOnly(),c=0,d=this.exceptions.length;d>c;c++)if(e.isSame(this.exceptions[c]))return this.exceptions.splice(c,1),this;return this}for(c=0,d=this.rules.length;d>c;c++)this.rules[c].measure===i(b)&&this.rules.splice(c,1)},n.prototype.hasRule=function(a){var b,c;for(b=0,c=this.rules.length;c>b;b++)if(this.rules[b].measure===i(a))return!0;return!1},n.prototype.matches=function(b,c){var d=a(b).dateOnly();if(!d.isValid())throw Error("Invalid date supplied to match method: "+b);return c||f(this.start,this.end,d)?h(this.exceptions,d)?!1:j(this.rules,d,this.start)?!0:!1:!1},n.prototype.next=function(a,b){return e.call(this,a,b,"next")},n.prototype.previous=function(a,b){return e.call(this,a,b,"previous")},n.prototype.all=function(a){return e.call(this,null,a,"all")};for(var o in m)l.hasOwnProperty(o)&&(n.prototype[o]=n.prototype[m[o]]=k(o));return n}();return a.recur=function(b,c){return new e(b!==Object(b)||a.isMoment(b)?{start:b,end:c}:b)},a.fn.recur=function(b,c){return b!==Object(b)||a.isMoment(b)?(c||(c=b,b=void 0),b||(b=this),new e({start:b,end:c,moment:this})):("undefined"==typeof b.start&&(b.start=this),new e(b))},a.fn.monthWeek=function(){var a=this.clone().startOf("month").startOf("week"),b=this.clone().startOf("week");return b.diff(a,"weeks")},a.fn.monthWeekByDay=function(){var a,b,c,d;return a=this.clone(),b=this.clone().startOf("month").startOf("week"),c=this.clone().startOf("week"),d=c.diff(b,"weeks"),a.subtract(d,"weeks").month()===this.clone().month()?d:d-1},a.fn.dateOnly=function(){return this.tz&&"function"==typeof a.tz?a.tz(this.format("YYYY/MM/DD"),"UTC"):this.hours(0).minutes(0).seconds(0).milliseconds(0).add(this.utcOffset(),"minute").utcOffset(0)},a});
{
"name": "moment-recur",
"version": "1.0.4",
"version": "1.0.5",
"description": "A momentjs plugin for matching and generating recurring dates.",

@@ -28,5 +28,5 @@ "main": "moment-recur.js",

"test": "gulp test",
"preinstall": "npm install bower gulp -g",
"preinstall": "npm install bower gulp",
"postinstall": "bower install"
}
}

@@ -210,2 +210,8 @@ moment-recur

.every("Februray").monthsOfYear();
// A weekOfMonthByDay interval is available for combining with
// the daysOfWeek to achieve "nth weekday of month" recurrences.
// The following matches every 1st and 3rd Thursday of the month.
cal = moment.recur().every("Thursday").daysOfWeek()
.every([0, 2]).weeksOfMonthByDay();
```

@@ -212,0 +218,0 @@

@@ -249,4 +249,51 @@ 'use strict';

});
it("should be possible to see if one exists", function() {
var recurrence = moment("01/01/2014").recur().every(1).day();
expect(recurrence.hasRule("days")).toBe(true);
expect(recurrence.hasRule("months")).toBe(false);
});
});
describe("weeksOfMonthByDay()", function() {
it("can recur on the 1st and 3rd Sundays of the month", function() {
var recurrence;
recurrence = moment.recur()
.every(["Sunday"]).daysOfWeek()
.every([0, 2]).weeksOfMonthByDay();
expect(recurrence.matches(moment(startDate))).toBe(false);
expect(recurrence.matches(moment(startDate).date(6))).toBe(true);
expect(recurrence.matches(moment(startDate).date(8))).toBe(false);
expect(recurrence.matches(moment(startDate).date(13))).toBe(false);
expect(recurrence.matches(moment(startDate).date(20))).toBe(true);
expect(recurrence.matches(moment(startDate).date(27))).toBe(false);
});
it("can recur on the 2nd, 4th and 5th Sundays and Thursdays of the month", function() {
var recurrence;
recurrence = moment.recur()
.every(["Sunday", "Thursday"]).daysOfWeek()
.every([1, 3, 4]).weeksOfMonthByDay();
expect(recurrence.matches(moment(startDate).date(6))).toBe(false);
expect(recurrence.matches(moment(startDate).date(13))).toBe(true);
expect(recurrence.matches(moment(startDate).date(20))).toBe(false);
expect(recurrence.matches(moment(startDate).date(27))).toBe(true);
expect(recurrence.matches(moment(startDate).date(3))).toBe(false);
expect(recurrence.matches(moment(startDate).date(10))).toBe(true);
expect(recurrence.matches(moment(startDate).date(17))).toBe(false);
expect(recurrence.matches(moment(startDate).date(24))).toBe(true);
expect(recurrence.matches(moment(startDate).date(31))).toBe(true);
});
it("will throw an error if used without daysOfWeek()", function() {
var recurrence, caught = { message: false };
try {
recurrence = moment.recur().every(0).weeksOfMonthByDay();
} catch (e) {
caught = e;
}
expect(caught.message).toBe('weeksOfMonthByDay must be combined with daysOfWeek');
});
});
describe("Future Dates", function() {

@@ -253,0 +300,0 @@ it("can be generated", function() {

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