ical.js
Advanced tools
Comparing version 1.2.2 to 1.3.0
@@ -716,3 +716,3 @@ /* This Source Code Form is subject to the terms of the Mozilla Public | ||
"language-tag": { | ||
matches: /^[a-zA-Z0-9\-]+$/ // Could go with a more strict regex here | ||
matches: /^[a-zA-Z0-9-]+$/ // Could go with a more strict regex here | ||
} | ||
@@ -719,0 +719,0 @@ }); |
@@ -27,3 +27,5 @@ /* This Source Code Form is subject to the terms of the Mozilla Public | ||
* @param {Array<ICAL.Component|ICAL.Event>} options.exceptions | ||
* Exceptions to this event, either as components or events | ||
* Exceptions to this event, either as components or events. If not | ||
* specified exceptions will automatically be set in relation of | ||
* component's parent | ||
*/ | ||
@@ -52,2 +54,8 @@ function Event(component, options) { | ||
options.exceptions.forEach(this.relateException, this); | ||
} else if (this.component.parent && !this.isRecurrenceException()) { | ||
this.component.parent.getAllSubcomponents('vevent').forEach(function(event) { | ||
if (event.hasProperty('recurrence-id')) { | ||
this.relateException(event); | ||
} | ||
}, this); | ||
} | ||
@@ -129,3 +137,7 @@ } | ||
modifiesFuture: function() { | ||
var range = this.component.getFirstPropertyValue('range'); | ||
if (!this.component.hasProperty('recurrence-id')) { | ||
return false; | ||
} | ||
var range = this.component.getFirstProperty('recurrence-id').getParameter('range'); | ||
return range === this.THISANDFUTURE; | ||
@@ -351,3 +363,4 @@ }, | ||
* The end date. This can be the result directly from the property, or the | ||
* end date calculated from start date and duration. | ||
* end date calculated from start date and duration. Setting the property | ||
* will remove any duration properties. | ||
* @type {ICAL.Time} | ||
@@ -370,2 +383,5 @@ */ | ||
set endDate(value) { | ||
if (this.component.hasProperty('duration')) { | ||
this.component.removeProperty('duration'); | ||
} | ||
this._setTime('dtend', value); | ||
@@ -376,5 +392,5 @@ }, | ||
* The duration. This can be the result directly from the property, or the | ||
* duration calculated from start date and end date. | ||
* duration calculated from start date and end date. Setting the property | ||
* will remove any `dtend` properties. | ||
* @type {ICAL.Duration} | ||
* @readonly | ||
*/ | ||
@@ -389,2 +405,10 @@ get duration() { | ||
set duration(value) { | ||
if (this.component.hasProperty('dtend')) { | ||
this.component.removeProperty('dtend'); | ||
} | ||
this._setProp('duration', value); | ||
}, | ||
/** | ||
@@ -391,0 +415,0 @@ * The location of the event. |
@@ -42,2 +42,62 @@ /* This Source Code Form is subject to the terms of the Mozilla Public | ||
/** | ||
* Compiles a list of all referenced TZIDs in all subcomponents and | ||
* removes any extra VTIMEZONE subcomponents. In addition, if any TZIDs | ||
* are referenced by a component, but a VTIMEZONE does not exist, | ||
* an attempt will be made to generate a VTIMEZONE using ICAL.TimezoneService. | ||
* | ||
* @param {ICAL.Component} vcal The top-level VCALENDAR component. | ||
* @return {ICAL.Component} The ICAL.Component that was passed in. | ||
*/ | ||
updateTimezones: function(vcal) { | ||
var allsubs, properties, vtimezones, reqTzid, i, tzid; | ||
if (!vcal || vcal.name !== "vcalendar") { | ||
//not a top-level vcalendar component | ||
return vcal; | ||
} | ||
//Store vtimezone subcomponents in an object reference by tzid. | ||
//Store properties from everything else in another array | ||
allsubs = vcal.getAllSubcomponents(); | ||
properties = []; | ||
vtimezones = {}; | ||
for (i = 0; i < allsubs.length; i++) { | ||
if (allsubs[i].name === "vtimezone") { | ||
tzid = allsubs[i].getFirstProperty("tzid").getFirstValue(); | ||
vtimezones[tzid] = allsubs[i]; | ||
} else { | ||
properties = properties.concat(allsubs[i].getAllProperties()); | ||
} | ||
} | ||
//create an object with one entry for each required tz | ||
reqTzid = {}; | ||
for (i = 0; i < properties.length; i++) { | ||
if ((tzid = properties[i].getParameter("tzid"))) { | ||
reqTzid[tzid] = true; | ||
} | ||
} | ||
//delete any vtimezones that are not on the reqTzid list. | ||
for (i in vtimezones) { | ||
if (vtimezones.hasOwnProperty(i) && !reqTzid[i]) { | ||
vcal.removeSubcomponent(vtimezones[i]); | ||
} | ||
} | ||
//create any missing, but registered timezones | ||
for (i in reqTzid) { | ||
if ( | ||
reqTzid.hasOwnProperty(i) && | ||
!vtimezones[i] && | ||
ICAL.TimezoneService.has(i) | ||
) { | ||
vcal.addSubcomponent(ICAL.TimezoneService.get(i).component); | ||
} | ||
} | ||
return vcal; | ||
}, | ||
/** | ||
* Checks if the given type is of the number type and also NaN. | ||
@@ -44,0 +104,0 @@ * |
@@ -222,2 +222,18 @@ /* This Source Code Form is subject to the terms of the Mozilla Public | ||
/** | ||
* Gets first parameter on the property. | ||
* | ||
* @param {String} name Property name (lowercase) | ||
* @return {String} Property value | ||
*/ | ||
getFirstParameter: function(name) { | ||
var parameters = this.getParameter(name); | ||
if (Array.isArray(parameters)) { | ||
return parameters[0]; | ||
} | ||
return parameters; | ||
}, | ||
/** | ||
* Sets a parameter on the property. | ||
@@ -224,0 +240,0 @@ * |
@@ -38,17 +38,17 @@ /* This Source Code Form is subject to the terms of the Mozilla Public | ||
* @alias ICAL.Recur | ||
* @param {Object} data An object with members of the recurrence | ||
* @param {ICAL.Recur.frequencyValues} freq The frequency value | ||
* @param {Number=} data.interval The INTERVAL value | ||
* @param {ICAL.Time.weekDay=} data.wkst The week start value | ||
* @param {ICAL.Time=} data.until The end of the recurrence set | ||
* @param {Number=} data.count The number of occurrences | ||
* @param {Array.<Number>=} data.bysecond The seconds for the BYSECOND part | ||
* @param {Array.<Number>=} data.byminute The minutes for the BYMINUTE part | ||
* @param {Array.<Number>=} data.byhour The hours for the BYHOUR part | ||
* @param {Array.<String>=} data.byday The BYDAY values | ||
* @param {Array.<Number>=} data.bymonthday The days for the BYMONTHDAY part | ||
* @param {Array.<Number>=} data.byyearday The days for the BYYEARDAY part | ||
* @param {Array.<Number>=} data.byweekno The weeks for the BYWEEKNO part | ||
* @param {Array.<Number>=} data.bymonth The month for the BYMONTH part | ||
* @param {Array.<Number>=} data.bysetpos The positionals for the BYSETPOS part | ||
* @param {Object} data An object with members of the recurrence | ||
* @param {ICAL.Recur.frequencyValues=} data.freq The frequency value | ||
* @param {Number=} data.interval The INTERVAL value | ||
* @param {ICAL.Time.weekDay=} data.wkst The week start value | ||
* @param {ICAL.Time=} data.until The end of the recurrence set | ||
* @param {Number=} data.count The number of occurrences | ||
* @param {Array.<Number>=} data.bysecond The seconds for the BYSECOND part | ||
* @param {Array.<Number>=} data.byminute The minutes for the BYMINUTE part | ||
* @param {Array.<Number>=} data.byhour The hours for the BYHOUR part | ||
* @param {Array.<String>=} data.byday The BYDAY values | ||
* @param {Array.<Number>=} data.bymonthday The days for the BYMONTHDAY part | ||
* @param {Array.<Number>=} data.byyearday The days for the BYYEARDAY part | ||
* @param {Array.<Number>=} data.byweekno The weeks for the BYWEEKNO part | ||
* @param {Array.<Number>=} data.bymonth The month for the BYMONTH part | ||
* @param {Array.<Number>=} data.bysetpos The positionals for the BYSETPOS part | ||
*/ | ||
@@ -243,17 +243,17 @@ ICAL.Recur = function icalrecur(data) { | ||
* | ||
* @param {Object} data An object with members of the recurrence | ||
* @param {ICAL.Recur.frequencyValues} freq The frequency value | ||
* @param {Number=} data.interval The INTERVAL value | ||
* @param {ICAL.Time.weekDay=} data.wkst The week start value | ||
* @param {ICAL.Time=} data.until The end of the recurrence set | ||
* @param {Number=} data.count The number of occurrences | ||
* @param {Array.<Number>=} data.bysecond The seconds for the BYSECOND part | ||
* @param {Array.<Number>=} data.byminute The minutes for the BYMINUTE part | ||
* @param {Array.<Number>=} data.byhour The hours for the BYHOUR part | ||
* @param {Array.<String>=} data.byday The BYDAY values | ||
* @param {Array.<Number>=} data.bymonthday The days for the BYMONTHDAY part | ||
* @param {Array.<Number>=} data.byyearday The days for the BYYEARDAY part | ||
* @param {Array.<Number>=} data.byweekno The weeks for the BYWEEKNO part | ||
* @param {Array.<Number>=} data.bymonth The month for the BYMONTH part | ||
* @param {Array.<Number>=} data.bysetpos The positionals for the BYSETPOS part | ||
* @param {Object} data An object with members of the recurrence | ||
* @param {ICAL.Recur.frequencyValues=} data.freq The frequency value | ||
* @param {Number=} data.interval The INTERVAL value | ||
* @param {ICAL.Time.weekDay=} data.wkst The week start value | ||
* @param {ICAL.Time=} data.until The end of the recurrence set | ||
* @param {Number=} data.count The number of occurrences | ||
* @param {Array.<Number>=} data.bysecond The seconds for the BYSECOND part | ||
* @param {Array.<Number>=} data.byminute The minutes for the BYMINUTE part | ||
* @param {Array.<Number>=} data.byhour The hours for the BYHOUR part | ||
* @param {Array.<String>=} data.byday The BYDAY values | ||
* @param {Array.<Number>=} data.bymonthday The days for the BYMONTHDAY part | ||
* @param {Array.<Number>=} data.byyearday The days for the BYYEARDAY part | ||
* @param {Array.<Number>=} data.byweekno The weeks for the BYWEEKNO part | ||
* @param {Array.<Number>=} data.bymonth The month for the BYMONTH part | ||
* @param {Array.<Number>=} data.bysetpos The positionals for the BYSETPOS part | ||
*/ | ||
@@ -275,2 +275,6 @@ fromData: function(data) { | ||
if (this.interval && typeof this.interval != "number") { | ||
optionDesign.INTERVAL(this.interval, this); | ||
} | ||
if (this.wkst && typeof this.wkst != "number") { | ||
@@ -343,3 +347,3 @@ this.wkst = ICAL.Recur.icalDayToNumericDay(this.wkst); | ||
if (this.until) { | ||
str += ';UNTIL=' + this.until.toString(); | ||
str += ';UNTIL=' + this.until.toICALString(); | ||
} | ||
@@ -446,11 +450,10 @@ if ('wkst' in this && this.wkst !== ICAL.Time.DEFAULT_WEEK_START) { | ||
UNTIL: function(value, dict, fmtIcal) { | ||
if (fmtIcal) { | ||
if (value.length > 10) { | ||
dict.until = ICAL.design.icalendar.value['date-time'].fromICAL(value); | ||
} else { | ||
dict.until = ICAL.design.icalendar.value.date.fromICAL(value); | ||
} | ||
if (value.length > 10) { | ||
dict.until = ICAL.design.icalendar.value['date-time'].fromICAL(value); | ||
} else { | ||
dict.until = ICAL.Time.fromString(value); | ||
dict.until = ICAL.design.icalendar.value.date.fromICAL(value); | ||
} | ||
if (!fmtIcal) { | ||
dict.until = ICAL.Time.fromString(dict.until); | ||
} | ||
}, | ||
@@ -501,17 +504,17 @@ | ||
* | ||
* @param {Object} aData An object with members of the recurrence | ||
* @param {ICAL.Recur.frequencyValues} freq The frequency value | ||
* @param {Number=} aData.interval The INTERVAL value | ||
* @param {ICAL.Time.weekDay=} aData.wkst The week start value | ||
* @param {ICAL.Time=} aData.until The end of the recurrence set | ||
* @param {Number=} aData.count The number of occurrences | ||
* @param {Array.<Number>=} aData.bysecond The seconds for the BYSECOND part | ||
* @param {Array.<Number>=} aData.byminute The minutes for the BYMINUTE part | ||
* @param {Array.<Number>=} aData.byhour The hours for the BYHOUR part | ||
* @param {Array.<String>=} aData.byday The BYDAY values | ||
* @param {Array.<Number>=} aData.bymonthday The days for the BYMONTHDAY part | ||
* @param {Array.<Number>=} aData.byyearday The days for the BYYEARDAY part | ||
* @param {Array.<Number>=} aData.byweekno The weeks for the BYWEEKNO part | ||
* @param {Array.<Number>=} aData.bymonth The month for the BYMONTH part | ||
* @param {Array.<Number>=} aData.bysetpos The positionals for the BYSETPOS part | ||
* @param {Object} aData An object with members of the recurrence | ||
* @param {ICAL.Recur.frequencyValues=} aData.freq The frequency value | ||
* @param {Number=} aData.interval The INTERVAL value | ||
* @param {ICAL.Time.weekDay=} aData.wkst The week start value | ||
* @param {ICAL.Time=} aData.until The end of the recurrence set | ||
* @param {Number=} aData.count The number of occurrences | ||
* @param {Array.<Number>=} aData.bysecond The seconds for the BYSECOND part | ||
* @param {Array.<Number>=} aData.byminute The minutes for the BYMINUTE part | ||
* @param {Array.<Number>=} aData.byhour The hours for the BYHOUR part | ||
* @param {Array.<String>=} aData.byday The BYDAY values | ||
* @param {Array.<Number>=} aData.bymonthday The days for the BYMONTHDAY part | ||
* @param {Array.<Number>=} aData.byyearday The days for the BYYEARDAY part | ||
* @param {Array.<Number>=} aData.byweekno The weeks for the BYWEEKNO part | ||
* @param {Array.<Number>=} aData.bymonth The month for the BYMONTH part | ||
* @param {Array.<Number>=} aData.bysetpos The positionals for the BYSETPOS part | ||
*/ | ||
@@ -518,0 +521,0 @@ ICAL.Recur.fromData = function(aData) { |
@@ -81,3 +81,4 @@ /* This Source Code Form is subject to the terms of the Mozilla Public | ||
var comps = component[2]; | ||
// Ignore subcomponents if none exist, e.g. in vCard. | ||
var comps = component[2] || []; | ||
var compIdx = 0; | ||
@@ -84,0 +85,0 @@ var compLen = comps.length; |
@@ -961,2 +961,8 @@ /* This Source Code Form is subject to the terms of the Mozilla Public | ||
set: function setTimeAttr(val) { | ||
// Check if isDate will be set and if was not set to normalize date. | ||
// This avoids losing days when seconds, minutes and hours are zeroed | ||
// what normalize will do when time is a date. | ||
if (attr === "isDate" && val && !this._time.isDate) { | ||
this.adjust(0, 0, 0, 0); | ||
} | ||
this._cachedUnixTime = null; | ||
@@ -963,0 +969,0 @@ this._pendingNormalization = true; |
{ | ||
"name": "ical.js", | ||
"version": "1.2.2", | ||
"version": "1.3.0", | ||
"author": "Philipp Kewisch", | ||
@@ -24,35 +24,30 @@ "contributors": [ | ||
"devDependencies": { | ||
"benchmark": "~2.1.1", | ||
"biased-opener": "^0.2.5", | ||
"chai": "~3.5", | ||
"closure-linter-wrapper": "^1.0.1", | ||
"coveralls": "^2.11.11", | ||
"grunt": "^1.0.1", | ||
"grunt-concurrent": "^2.0.0", | ||
"grunt-contrib-concat": "^1.0.0", | ||
"grunt-contrib-uglify": "^2.0.0", | ||
"grunt-coveralls": "^1.0.0", | ||
"grunt-gh-pages": "^1.0.0", | ||
"grunt-jsdoc": "^2.0.0", | ||
"grunt-karma": "^1.0.0", | ||
"grunt-mocha-cli": "^2.0.0", | ||
"grunt-mocha-istanbul": "^5.0.1", | ||
"benchmark": "^2.1.4", | ||
"biased-opener": "^0.2.8", | ||
"chai": "^4.1.2", | ||
"coveralls": "^3.0.2", | ||
"grunt": "^1.0.3", | ||
"grunt-concurrent": "^2.3.1", | ||
"grunt-contrib-concat": "^1.0.1", | ||
"grunt-contrib-uglify": "^3.3.0", | ||
"grunt-coveralls": "^2.0.0", | ||
"grunt-gh-pages": "^3.0.0", | ||
"grunt-jsdoc": "^2.2.1", | ||
"grunt-karma": "^2.0.0", | ||
"grunt-mocha-cli": "^4.0.0", | ||
"grunt-mocha-istanbul": "^5.0.2", | ||
"grunt-release": "^0.14.0", | ||
"gruntify-eslint": "^2.0.0", | ||
"istanbul": "^0.4.2", | ||
"karma": "^1.0.0", | ||
"gruntify-eslint": "^5.0.0", | ||
"istanbul": "^0.4.5", | ||
"karma": "^2.0.4", | ||
"karma-chai": "^0.1.0", | ||
"karma-mocha": "^1.1.1", | ||
"karma-sauce-launcher": "^1.0.0", | ||
"karma-spec-reporter": "^0.0.26", | ||
"minami": "^1.1.0", | ||
"mocha": "~2.5.3", | ||
"node-static": "^0.7.6", | ||
"open": "0.0.5", | ||
"sync-exec": "^0.6.0", | ||
"test-agent": "~0.28.2" | ||
"karma-mocha": "^1.3.0", | ||
"karma-sauce-launcher": "^1.2.0", | ||
"karma-spec-reporter": "^0.0.32", | ||
"minami": "^1.2.3", | ||
"mocha": "^5.2.0" | ||
}, | ||
"license": "MPL-2.0", | ||
"engine": { | ||
"node": ">=0.4" | ||
"node": ">=6" | ||
}, | ||
@@ -59,0 +54,0 @@ "scripts": { |
@@ -19,4 +19,4 @@ # jsical - Javascript parser for rfc5545 | ||
[![Build Status](https://secure.travis-ci.org/mozilla-comm/ical.js.png?branch=master)](http://travis-ci.org/mozilla-comm/ical.js) [![Coverage Status](https://coveralls.io/repos/mozilla-comm/ical.js/badge.svg)](https://coveralls.io/r/mozilla-comm/ical.js) [![npm version](https://badge.fury.io/js/ical.js.svg)](http://badge.fury.io/js/ical.js) | ||
[![Dependency Status](https://david-dm.org/mozilla-comm/ical.js.svg)](https://david-dm.org/mozilla-comm/ical.js) [![devDependency Status](https://david-dm.org/mozilla-comm/ical.js/dev-status.svg)](https://david-dm.org/mozilla-comm/ical.js#info=devDependencies) | ||
[![Build Status](https://secure.travis-ci.org/mozilla-comm/ical.js.png?branch=master)](http://travis-ci.org/mozilla-comm/ical.js) [![Coverage Status](https://coveralls.io/repos/mozilla-comm/ical.js/badge.svg)](https://coveralls.io/r/mozilla-comm/ical.js) [![npm version](https://badge.fury.io/js/ical.js.svg)](http://badge.fury.io/js/ical.js) [![CDNJS](https://img.shields.io/cdnjs/v/ical.js.svg)](https://cdnjs.com/libraries/ical.js) | ||
[![Greenkeeper badge](https://badges.greenkeeper.io/mozilla-comm/ical.js.svg)](https://greenkeeper.io/) [![Dependency Status](https://david-dm.org/mozilla-comm/ical.js.svg)](https://david-dm.org/mozilla-comm/ical.js) [![devDependency Status](https://david-dm.org/mozilla-comm/ical.js/dev-status.svg)](https://david-dm.org/mozilla-comm/ical.js?type=dev) | ||
@@ -38,3 +38,3 @@ ## Sandbox and Validator | ||
You can install ICAL.js via [npm](https://www.npmjs.com/), if you would like to | ||
use it in node: | ||
use it in Node.js: | ||
``` | ||
@@ -51,3 +51,3 @@ npm install ical.js | ||
ICAL.js has no dependencies and uses fairly basic JavaScript. Therefore, it | ||
should work in all versions of node and modern browsers. It does use getters | ||
should work in all versions of Node.js and modern browsers. It does use getters | ||
and setters, so the minimum version of Internet Explorer is 9. | ||
@@ -65,8 +65,17 @@ | ||
To contribute to ICAL.js you need to set up the development environment. This | ||
requires node 0.10.x or later and grunt. Run the following steps to get | ||
requires Node.js 4.x or later and grunt. Run the following steps to get | ||
started. | ||
npm install -g grunt-cli # Might need to run with sudo | ||
npm install . | ||
Preferred way (to match building and packaging with official process): | ||
``` | ||
yarn global add grunt-cli # Might need to run with sudo | ||
yarn --frozen-lockfile | ||
``` | ||
Alternative way: | ||
``` | ||
npm install -g grunt-cli # Might need to run with sudo | ||
npm install . | ||
``` | ||
You can now dive into the code, run the tests and check coverage. | ||
@@ -76,10 +85,10 @@ | ||
Tests can either be run via node or in the browser, but setting up the testing | ||
infrastructure requires [node](https://github.com/joyent/node). More | ||
Tests can either be run via Node.js or in the browser, but setting up the testing | ||
infrastructure requires [node](https://github.com/nodejs/node). More | ||
information on how to set up and run tests can be found on | ||
[the wiki](https://github.com/mozilla-comm/ical.js/wiki/Running-Tests). | ||
#### in node js | ||
#### in Node.js | ||
The quickest way to execute tests is using node. Running the following command | ||
The quickest way to execute tests is using Node.js. Running the following command | ||
will run all test suites: performance, acceptance and unit tests. | ||
@@ -95,3 +104,3 @@ | ||
grunt test-node:single --test test/parse_test.js | ||
grunt test-node:single --test=test/parse_test.js | ||
@@ -110,10 +119,10 @@ Appending the `--debug` option to any of the above commands will run the | ||
#### in the browser (with karma) | ||
#### in the browser | ||
There are currently two ways to run the browser tests because we are currently | ||
experimenting with using [karma](http://karma-runner.github.io/). To run tests | ||
with karma, you can run the following targets: | ||
To run the browser tests, we are currently using [karma](http://karma-runner.github.io/). | ||
To run tests with karma, you can run the following targets: | ||
grunt test-browser # run all tests | ||
grunt karma:unit # run only the unit tests | ||
grunt karma:acceptance # run the acceptance tests | ||
grunt karma:acceptance # run only the acceptance tests | ||
@@ -124,3 +133,3 @@ Now you can visit [http://localhost:9876](http://localhost:9876) in your | ||
grunt karma:single --test test/parse_test.js | ||
grunt karma:single --test=test/parse_test.js | ||
@@ -138,8 +147,2 @@ The mentioned targets all run the tests from start to finish. If you would like | ||
#### in the browser (the old way) | ||
Running `grunt test-server` will start a webserver and open the page in your | ||
browser. You can then select and execute tests as you wish. If you want to run | ||
all tests you can also open a second terminal and run `grunt test-browser` | ||
### Code Coverage | ||
@@ -146,0 +149,0 @@ ICAL.js is set up to calculate code coverage. You can |
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is too big to display
Copyleft License
License(Experimental) Copyleft license information was found
Found 1 instance in 1 package
Mixed license
License(Experimental) Package contains multiple licenses.
Found 1 instance in 1 package
Non-permissive License
License(Experimental) A license not known to be considered permissive was found
Found 1 instance in 1 package
Copyleft License
License(Experimental) Copyleft license information was found
Found 1 instance in 1 package
Non-permissive License
License(Experimental) A license not known to be considered permissive was found
Found 1 instance in 1 package
661867
24
25
16701
168
3