Commit 7d4b8b78 authored by Andi Sidwell's avatar Andi Sidwell
Browse files

Ensure that timezone and floating settings are mutually exclusive

parent ac8a80eb
......@@ -7,7 +7,7 @@
* @constructor ICalEvent Event
*/
var ICalEvent = function(_data) {
var attributes = ['id', 'uid', 'start', 'end', 'stamp', 'timestamp', 'allDay', 'floating', 'repeating', 'summary', 'location', 'description', 'organizer', 'attendees', 'alarms', 'method', 'status', 'url'],
var attributes = ['id', 'uid', 'start', 'end', 'timezone', 'stamp', 'timestamp', 'allDay', 'floating', 'repeating', 'summary', 'location', 'description', 'organizer', 'attendees', 'alarms', 'method', 'status', 'url'],
vars,
i,
data;
......@@ -126,12 +126,12 @@ var ICalEvent = function(_data) {
/**
* Set/Get the event's timezone.
* Set/Get the event's timezone. This unsets the event's floating flag.
* Used on date properties
*
* @param [timezone] Timezone
* @example event.timezone('America/New_York');
* @since 0.2.5
* @since 0.2.6
* @returns {ICalEvent|String}
*/
this.timezone = function(timezone) {
......@@ -140,6 +140,7 @@ var ICalEvent = function(_data) {
}
data.timezone = timezone.toString();
data.floating = false;
return this;
};
......@@ -196,7 +197,7 @@ var ICalEvent = function(_data) {
/**
* Set/Get the event's floating flag
* Set/Get the event's floating flag. This unsets the event's timezone.
* See https://tools.ietf.org/html/rfc5545#section-3.3.12
*
* @param {Boolean} floating
......@@ -209,6 +210,7 @@ var ICalEvent = function(_data) {
}
data.floating = !!floating;
data.timezone = null;
return this;
};
......
......@@ -147,7 +147,7 @@ describe('ical-generator 0.2.x / ICalCalendar', function() {
assert.equal(cal.timezone(), 'Europe/Berlin');
});
it('should change something', function() {
it('should make a difference to iCal output', function() {
var cal = ical().timezone('Europe/London');
cal.createEvent({
start: new Date(),
......@@ -156,6 +156,20 @@ describe('ical-generator 0.2.x / ICalCalendar', function() {
});
assert.ok(cal.toString().indexOf('Europe/London') > -1);
});
it('should mark event as not floating', function() {
var cal = ical().timezone('Europe/London'),
evt = cal.createEvent({
start: new Date(),
end: new Date(new Date().getTime() + 3600000),
summary: 'Example Event',
floating: true
});
evt.timezone('Europe/Berlin');
assert.equal(evt.floating(), false);
});
});
describe('ttl()', function() {
......@@ -579,6 +593,20 @@ describe('ical-generator 0.2.x / ICalCalendar', function() {
event.floating(true);
assert.ok(str !== cal.toString());
});
it('should mark event as having no time zone', function() {
var cal = ical().timezone('Europe/London'),
evt = cal.createEvent({
start: new Date(),
end: new Date(new Date().getTime() + 3600000),
summary: 'Example Event',
timezone: 'Europe/Berlin'
});
evt.floating(true);
assert.equal(evt.timezone(), null);
});
});
describe('repeating()', function() {
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment