Skip to content

Commit 3b8b3f7

Browse files
committed
yahoo fix
1 parent 3bb768b commit 3b8b3f7

File tree

1 file changed

+15
-2
lines changed

1 file changed

+15
-2
lines changed

src/atcb-links.js

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -309,9 +309,22 @@ function atcb_generate_yahoo(data, date, subEvent = 'all') {
309309
urlParts.push('https://calendar.yahoo.com/?v=60');
310310
// generate and add date
311311
const formattedDate = atcb_generate_time(date, 'clean');
312-
urlParts.push('st=' + encodeURIComponent(formattedDate.start) + '&et=' + encodeURIComponent(formattedDate.end));
313312
if (formattedDate.allday) {
314-
urlParts.push('dur=allday');
313+
if (formattedDate.start === formattedDate.end) {
314+
urlParts.push('dur=allday&st=' + encodeURIComponent(formattedDate.start)); // for all-day events, we may only set the start date
315+
} else {
316+
// however, if it spans multiple days, we need to set a time instead of all-day
317+
// therefore, we copy the data object, add startTime "00:00" and endTime "23:59" and generate the time again with timeZone being set to the user's timeZone
318+
// TODO: Remove this workaround, when Yahoo allows all-day events spanning multiple days
319+
const allDayDate = JSON.parse(JSON.stringify(date));
320+
allDayDate.startTime = '00:00';
321+
allDayDate.endTime = '23:59';
322+
allDayDate.timeZone = Intl.DateTimeFormat().resolvedOptions().timeZone;
323+
const formattedAllDayDate = atcb_generate_time(allDayDate, 'clean');
324+
urlParts.push('st=' + encodeURIComponent(formattedAllDayDate.start) + '&et=' + encodeURIComponent(formattedAllDayDate.end));
325+
}
326+
} else {
327+
urlParts.push('st=' + encodeURIComponent(formattedDate.start) + '&et=' + encodeURIComponent(formattedDate.end));
315328
}
316329
// add details (if set)
317330
if (date.name && date.name !== '') {

0 commit comments

Comments
 (0)