Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
SRCT
lib-ical
Commits
7d4b8b78
Commit
7d4b8b78
authored
Dec 08, 2015
by
Andi Sidwell
Browse files
Ensure that timezone and floating settings are mutually exclusive
parent
ac8a80eb
Changes
2
Hide whitespace changes
Inline
Side-by-side
lib/event.js
View file @
7d4b8b78
...
...
@@ -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
;
};
...
...
test/test_0.2.x.js
View file @
7d4b8b78
...
...
@@ -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
()
{
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment