Skip to content

Commit

Permalink
yahoo fix
Browse files Browse the repository at this point in the history
  • Loading branch information
jekuer committed May 15, 2024
1 parent 3bb768b commit 3b8b3f7
Showing 1 changed file with 15 additions and 2 deletions.
17 changes: 15 additions & 2 deletions src/atcb-links.js
Original file line number Diff line number Diff line change
Expand Up @@ -309,9 +309,22 @@ function atcb_generate_yahoo(data, date, subEvent = 'all') {
urlParts.push('https://calendar.yahoo.com/?v=60');
// generate and add date
const formattedDate = atcb_generate_time(date, 'clean');
urlParts.push('st=' + encodeURIComponent(formattedDate.start) + '&et=' + encodeURIComponent(formattedDate.end));
if (formattedDate.allday) {
urlParts.push('dur=allday');
if (formattedDate.start === formattedDate.end) {
urlParts.push('dur=allday&st=' + encodeURIComponent(formattedDate.start)); // for all-day events, we may only set the start date
} else {
// however, if it spans multiple days, we need to set a time instead of all-day
// 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
// TODO: Remove this workaround, when Yahoo allows all-day events spanning multiple days
const allDayDate = JSON.parse(JSON.stringify(date));
allDayDate.startTime = '00:00';
allDayDate.endTime = '23:59';
allDayDate.timeZone = Intl.DateTimeFormat().resolvedOptions().timeZone;
const formattedAllDayDate = atcb_generate_time(allDayDate, 'clean');
urlParts.push('st=' + encodeURIComponent(formattedAllDayDate.start) + '&et=' + encodeURIComponent(formattedAllDayDate.end));
}
} else {
urlParts.push('st=' + encodeURIComponent(formattedDate.start) + '&et=' + encodeURIComponent(formattedDate.end));
}
// add details (if set)
if (date.name && date.name !== '') {
Expand Down

0 comments on commit 3b8b3f7

Please sign in to comment.