Comparing version 1.1.5 to 1.1.6
@@ -632,3 +632,3 @@ // Generated by CoffeeScript 1.8.0 | ||
VEvent.prototype.extract = function() { | ||
VEvent.prototype.extract = function(defaultTimezone) { | ||
var allDay, attendees, created, daysNum, dtend, dtstart, duration, endDate, hoursNum, iCalFormat, lastModification, minutesNum, mozLastack, rrule, rruleOptions, secondsNum, stampDate, startDate, timezone, timezoneEnd, timezoneStart, uid, weeksNum, _, _ref1, _ref10, _ref11, _ref2, _ref3, _ref4, _ref5, _ref6, _ref7, _ref8, _ref9; | ||
@@ -652,3 +652,7 @@ iCalFormat = 'YYYYMMDDTHHmmss'; | ||
} else { | ||
timezoneStart = 'UTC'; | ||
if (dtstart.value.length === 15) { | ||
timezoneStart = defaultTimezone; | ||
} else { | ||
timezoneStart = 'UTC'; | ||
} | ||
} | ||
@@ -682,3 +686,7 @@ } else { | ||
} else { | ||
timezoneEnd = 'UTC'; | ||
if (dtstart.value.length === 15) { | ||
timezoneEnd = defaultTimezone; | ||
} else { | ||
timezoneEnd = 'UTC'; | ||
} | ||
} | ||
@@ -891,8 +899,20 @@ endDate = moment.tz(endDate, iCalFormat, timezoneEnd).toDate(); | ||
ICalParser.prototype.parseFile = function(file, callback) { | ||
ICalParser.prototype.parseFile = function(file, options, callback) { | ||
if (arguments.length < 3) { | ||
callback = options; | ||
this.defaultTimezone = 'UTC'; | ||
} else { | ||
this.defaultTimezone = options.defaultTimezone || 'UTC'; | ||
} | ||
return this.parse(fs.createReadStream(file), callback); | ||
}; | ||
ICalParser.prototype.parseString = function(string, callback) { | ||
ICalParser.prototype.parseString = function(string, options, callback) { | ||
var fakeStream; | ||
if (arguments.length < 3) { | ||
callback = options; | ||
this.defaultTimezone = 'UTC'; | ||
} else { | ||
this.defaultTimezone = options.defaultTimezone || 'UTC'; | ||
} | ||
fakeStream = new stream.Readable(); | ||
@@ -946,31 +966,33 @@ fakeStream._read = function() {}; | ||
}; | ||
lineParser = function(line) { | ||
var detail, details, key, pname, pvalue, tuple, value, _i, _len, _ref1, _ref2, _results; | ||
tuple = line.trim().split(':'); | ||
if (tuple.length < 2) { | ||
return sendError("Malformed ical file"); | ||
} else { | ||
key = tuple.shift(); | ||
value = tuple.join(':'); | ||
if (key === "BEGIN") { | ||
return createComponent(value); | ||
} else if (key === "END") { | ||
component.extract(); | ||
return component = component.parent; | ||
} else if (!((component != null) || (result != null))) { | ||
lineParser = (function(_this) { | ||
return function(line) { | ||
var detail, details, key, pname, pvalue, tuple, value, _i, _len, _ref1, _ref2, _results; | ||
tuple = line.trim().split(':'); | ||
if (tuple.length < 2) { | ||
return sendError("Malformed ical file"); | ||
} else if ((key != null) && key !== '' && (component != null)) { | ||
_ref1 = key.split(';'), key = _ref1[0], details = 2 <= _ref1.length ? __slice.call(_ref1, 1) : []; | ||
component.addRawField(key, value, details); | ||
_results = []; | ||
for (_i = 0, _len = details.length; _i < _len; _i++) { | ||
detail = details[_i]; | ||
_results.push((_ref2 = detail.split('='), pname = _ref2[0], pvalue = _ref2[1], _ref2)); | ||
} else { | ||
key = tuple.shift(); | ||
value = tuple.join(':'); | ||
if (key === "BEGIN") { | ||
return createComponent(value); | ||
} else if (key === "END") { | ||
component.extract(_this.defaultTimezone); | ||
return component = component.parent; | ||
} else if (!((component != null) || (result != null))) { | ||
return sendError("Malformed ical file"); | ||
} else if ((key != null) && key !== '' && (component != null)) { | ||
_ref1 = key.split(';'), key = _ref1[0], details = 2 <= _ref1.length ? __slice.call(_ref1, 1) : []; | ||
component.addRawField(key, value, details); | ||
_results = []; | ||
for (_i = 0, _len = details.length; _i < _len; _i++) { | ||
detail = details[_i]; | ||
_results.push((_ref2 = detail.split('='), pname = _ref2[0], pvalue = _ref2[1], _ref2)); | ||
} | ||
return _results; | ||
} else { | ||
return sendError("Malformed ical file"); | ||
} | ||
return _results; | ||
} else { | ||
return sendError("Malformed ical file"); | ||
} | ||
} | ||
}; | ||
}; | ||
})(this); | ||
return stream.on('data', function(line) { | ||
@@ -977,0 +999,0 @@ stream.pause(); |
{ | ||
"name": "cozy-ical", | ||
"version": "1.1.5", | ||
"version": "1.1.6", | ||
"description": "Cozy-Ical provides ICal Parser, generators and helpers", | ||
@@ -5,0 +5,0 @@ "main": "lib/index", |
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
82282
20
1859