Commit 069f5932 authored by Andi Sidwell's avatar Andi Sidwell
Browse files

Add event timezone method

parent b76ed63e
......@@ -22,6 +22,7 @@ var ICalEvent = function(_data) {
id: ('0000' + (Math.random() * Math.pow(36, 4) << 0).toString(36)).substr(-4),
start: null,
end: null,
timezone: null,
stamp: new Date(),
allDay: false,
floating: false,
......@@ -124,6 +125,25 @@ var ICalEvent = function(_data) {
};
/**
* Set/Get the event's timezone.
* Used on date properties
*
* @param [timezone] Timezone
* @example event.timezone('America/New_York');
* @since 0.2.5
* @returns {ICalEvent|String}
*/
this.timezone = function(timezone) {
if(!timezone) {
return data.timezone;
}
data.timezone = timezone.toString();
return this;
};
/**
* Set/Get the event's timestamp
*
......
......@@ -467,6 +467,19 @@ describe('ical-generator 0.2.x / ICalCalendar', function() {
});
});
describe('timezone()', function() {
it('setter should return this', function() {
var e = ical().createEvent();
assert.deepEqual(e, e.timezone('Europe/Berlin'));
});
it('getter should return value', function() {
var e = ical().createEvent().timezone('Europe/Berlin');
assert.equal(e.timezone(), 'Europe/Berlin');
});
});
describe('stamp()', function() {
it('setter should return this', function() {
var e = ical().createEvent();
......
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