Skip to content
This repository was archived by the owner on Aug 15, 2020. It is now read-only.
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions lib/base.js
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ var properties = exports.properties = {
COMPLETED: { type: 'DATE-TIME' },
DTEND: { type: 'DATE-TIME' },
DUE: { type: 'DATE-TIME' },
DTSTART: { type: 'DATE-TIME' },
DTSTART: { type: 'DATE-TIME', altType: 'DATE' },
DURATION: { type: 'DURATION' },
FREEBUSY: { type: 'PERIOD' },
TRANSP: { type: 'TEXT' },
Expand Down Expand Up @@ -130,10 +130,10 @@ CalendarObject.prototype.addProperties = function(props) {
props.forEach(this.addProperty.bind(this));
}

CalendarObject.prototype.addProperty = function(prop, value, parameters) {
CalendarObject.prototype.addProperty = function(prop, value, parameters, useAltType) {
if(!(prop instanceof CalendarProperty)) {
if(value === undefined) return;
prop = new CalendarProperty(prop, value, parameters);
prop = new CalendarProperty(prop, value, parameters, useAltType);
}
else
prop = prop.clone();
Expand Down Expand Up @@ -240,10 +240,10 @@ CalendarObject.prototype.format = function() {



var CalendarProperty = exports.CalendarProperty = function(name, value, parameters) {
var CalendarProperty = exports.CalendarProperty = function(name, value, parameters, useAltType) {
var propdef = properties[name];

this.type = propdef && propdef.type ? propdef.type : 'TEXT';
this.type = propdef && propdef[useAltType ? 'altType' : 'type'] ? propdef[useAltType ? 'altType' : 'type'] : 'TEXT';
this.name = name;
this.value = value;
this.parameters = parameters || {};
Expand Down
13 changes: 8 additions & 5 deletions lib/event.js
Original file line number Diff line number Diff line change
Expand Up @@ -59,11 +59,14 @@ VEvent.prototype.setDescription = function(desc) {
}

VEvent.prototype.setDate = function(start, end) {
this.addProperty('DTSTART', start);
if(end instanceof Date)
this.addProperty('DTEND', end);
else
this.addProperty('DURATION', end);
var allDay = (typeof end === 'undefined');
this.addProperty('DTSTART', start, {}, allDay);
if(!allDay) {
if(end instanceof Date)
this.addProperty('DTEND', end);
else
this.addProperty('DURATION', end);
}
}

VEvent.prototype.rrule = function() {
Expand Down