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
7f1494c3
Commit
7f1494c3
authored
Sep 13, 2016
by
Sebastian
Committed by
GitHub
Sep 13, 2016
Browse files
Merge pull request #44 from srct/develop
Add exclude date feature to repeating events.
parents
4cdb0c71
44c7f7ad
Changes
4
Hide whitespace changes
Inline
Side-by-side
lib/event.js
View file @
7f1494c3
...
...
@@ -346,6 +346,26 @@ var ICalEvent = function(_data, calendar) {
});
}
if
(
repeating
.
exclude
)
{
if
(
!
Array
.
isArray
(
repeating
.
exclude
))
{
repeating
.
exclude
=
[
repeating
.
exclude
];
}
data
.
repeating
.
exclude
=
[];
repeating
.
exclude
.
forEach
(
function
(
excludedDate
)
{
var
originalDate
=
excludedDate
;
if
(
typeof
(
excludedDate
==
'
string
'
))
{
excludedDate
=
new
Date
(
excludedDate
);
}
if
(
Object
.
prototype
.
toString
.
call
(
excludedDate
)
!==
'
[object Date]
'
||
isNaN
(
excludedDate
.
getTime
()))
{
throw
'
`repeating.exclude` contains invalid value `
'
+
originalDate
+
'
`!
'
;
}
data
.
repeating
.
exclude
.
push
(
excludedDate
);
});
}
return
this
;
};
...
...
@@ -688,6 +708,18 @@ var ICalEvent = function(_data, calendar) {
}
g
+=
'
\r\n
'
;
// REPEATING EXCLUSION
if
(
data
.
repeating
.
exclude
)
{
g
+=
'
EXDATE:
'
;
var
sArr
=
[];
data
.
repeating
.
exclude
.
forEach
(
function
(
excludedDate
)
{
sArr
.
push
(
tools
.
formatDate
(
excludedDate
));
});
g
+=
sArr
.
join
(
'
,
'
);
g
+=
'
\r\n
'
;
}
}
// SUMMARY
...
...
test/results/generate_04.ics
View file @
7f1494c3
...
...
@@ -8,6 +8,7 @@ DTSTAMP:20131004T233453Z
DTSTART:20131004T223930Z
DTEND:20131006T231500Z
RRULE:FREQ=MONTHLY
EXDATE:20131006T231500Z
SUMMARY:repeating by month
END:VEVENT
BEGIN:VEVENT
...
...
test/test_0.1.x.js
View file @
7f1494c3
...
...
@@ -293,6 +293,42 @@ describe('ical-generator 0.1.x', function() {
},
/event
\.
repeating
\.
until must be a Date Object/
);
});
it
(
'
should throw error when repeating.exclude is not valid
'
,
function
()
{
var
generator
=
require
(
__dirname
+
'
/../lib/index.js
'
),
cal
=
generator
();
assert
.
throws
(
function
()
{
cal
.
createEvent
({
start
:
new
Date
(),
end
:
new
Date
(),
summary
:
'
test
'
,
repeating
:
{
freq
:
'
DAILY
'
,
interval
:
2
,
byDay
:
[
'
SU
'
],
exclude
:
'
FOO
'
}
});
},
/`repeating
\.
exclude` contains invalid value `FOO`/
);
});
it
(
'
should throw error when repeating.exclude is not valid (should throw on first err value
'
,
function
()
{
var
generator
=
require
(
__dirname
+
'
/../lib/index.js
'
),
cal
=
generator
();
assert
.
throws
(
function
()
{
cal
.
createEvent
({
start
:
new
Date
(),
end
:
new
Date
(),
summary
:
'
test
'
,
repeating
:
{
freq
:
'
DAILY
'
,
interval
:
2
,
byDay
:
[
'
SU
'
],
exclude
:
[
new
Date
(),
'
BAR
'
,
'
FOO
'
]
}
});
},
/`repeating
\.
exclude` contains invalid value `BAR`/
);
});
it
(
'
should throw error when summary is empty
'
,
function
()
{
var
generator
=
require
(
__dirname
+
'
/../lib/index.js
'
),
cal
=
generator
();
...
...
@@ -470,7 +506,8 @@ describe('ical-generator 0.1.x', function() {
stamp
:
new
Date
(
'
Fr Oct 04 2013 23:34:53 UTC
'
),
summary
:
'
repeating by month
'
,
repeating
:
{
freq
:
'
MONTHLY
'
freq
:
'
MONTHLY
'
,
exclude
:
new
Date
(
'
Fr Oct 06 2013 23:15:00 UTC
'
)
}
});
...
...
test/test_0.2.x.js
View file @
7f1494c3
...
...
@@ -791,12 +791,13 @@ describe('ical-generator 0.2.x / ICalCalendar', function() {
freq
:
'
monthly
'
,
count
:
5
,
interval
:
2
,
exclude
:
new
Date
(),
unitl
:
new
Date
()
}));
});
it
(
'
getter should return value
'
,
function
()
{
var
options
=
{
freq
:
'
MONTHLY
'
,
count
:
5
,
interval
:
2
,
until
:
new
Date
()},
var
options
=
{
freq
:
'
MONTHLY
'
,
count
:
5
,
interval
:
2
,
exclude
:
new
Date
(),
until
:
new
Date
()},
e
=
ical
().
createEvent
();
assert
.
deepEqual
(
e
.
repeating
(),
null
);
e
.
repeating
(
options
);
...
...
@@ -986,6 +987,40 @@ describe('ical-generator 0.2.x / ICalCalendar', function() {
});
},
/`repeating
\.
byMonthDay` contains invalid value `32`/
);
});
it
(
'
should throw error when repeating.exclude is not valid
'
,
function
()
{
var
cal
=
ical
();
assert
.
throws
(
function
()
{
cal
.
createEvent
({
start
:
new
Date
(),
end
:
new
Date
(),
summary
:
'
test
'
,
repeating
:
{
freq
:
'
DAILY
'
,
interval
:
2
,
byDay
:
[
'
SU
'
],
exclude
:
'
FOO
'
}
});
},
/`repeating
\.
exclude` contains invalid value `FOO`/
);
});
it
(
'
should throw error when repeating.exclude is not valid (should throw on first err value
'
,
function
()
{
var
cal
=
ical
();
assert
.
throws
(
function
()
{
cal
.
createEvent
({
start
:
new
Date
(),
end
:
new
Date
(),
summary
:
'
test
'
,
repeating
:
{
freq
:
'
DAILY
'
,
interval
:
2
,
byDay
:
[
'
SU
'
],
exclude
:
[
new
Date
(),
'
BAR
'
,
'
FOO
'
]
}
});
},
/`repeating
\.
exclude` contains invalid value `BAR`/
);
});
});
describe
(
'
summary()
'
,
function
()
{
...
...
@@ -1443,7 +1478,8 @@ describe('ical-generator 0.2.x / ICalCalendar', function() {
stamp
:
new
Date
(
'
Fr Oct 04 2013 23:34:53 UTC
'
),
summary
:
'
repeating by month
'
,
repeating
:
{
freq
:
'
monthly
'
freq
:
'
monthly
'
,
exclude
:
new
Date
(
'
Fr Oct 06 2013 23:15:00 UTC
'
)
}
},
{
...
...
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