* @param {TemplateDef} template * @return {object}
(template)
| 302 | * @return {object} |
| 303 | */ |
| 304 | function getNextIssueData(template) { |
| 305 | const { |
| 306 | calendarEventDetails, |
| 307 | calendarEventTitle, |
| 308 | createBody, |
| 309 | createTitle, |
| 310 | generateWeeksFromNow, |
| 311 | labels, |
| 312 | sessionDurationHours, |
| 313 | timeRotationStart, |
| 314 | timeRotationUtc, |
| 315 | } = template; |
| 316 | |
| 317 | const upcomingWeekday = addDays(new Date(), generateWeeksFromNow * 7); |
| 318 | |
| 319 | const [dayOfWeek, timeUtcNoDst, region] = getRotation( |
| 320 | timeRotationUtc, |
| 321 | upcomingWeekday, |
| 322 | timeRotationStart |
| 323 | ); |
| 324 | |
| 325 | const nextDay = addDays( |
| 326 | upcomingWeekday, |
| 327 | dayOfWeek - upcomingWeekday.getDay() |
| 328 | ); |
| 329 | const [hoursUnadjusted, minutes] = timeUtcNoDst.split(':').map(Number); |
| 330 | const hours = hoursUnadjusted - (isDaylightSavingsUsa(nextDay) ? 1 : 0); |
| 331 | |
| 332 | const yyyy = nextDay.getFullYear(); |
| 333 | const mm = leadingZero(nextDay.getMonth() + 1); |
| 334 | const dd = leadingZero(nextDay.getDate()); |
| 335 | |
| 336 | const timeUtc = `${leadingZero(hours)}:${leadingZero(minutes)}`; |
| 337 | |
| 338 | const timeUrl = `https://www.timeanddate.com/worldclock/meeting.html?year=${yyyy}&month=${mm}&day=${dd}&iv=0`; |
| 339 | |
| 340 | const startZ = timeZ(yyyy, mm, dd, hours, minutes); |
| 341 | const endZ = timeZ(yyyy, mm, dd, hours + sessionDurationHours, minutes); |
| 342 | |
| 343 | const calendarUrl = `http://www.google.com/calendar/event?action=TEMPLATE&text=${encodeURIComponent( |
| 344 | calendarEventTitle |
| 345 | )}&dates=${startZ}/${endZ}&details=${encodeURIComponent( |
| 346 | calendarEventDetails |
| 347 | )}`; |
| 348 | |
| 349 | const templateData = { |
| 350 | datetimeUtc: getParseableDatetimeUtc(yyyy, mm, dd, timeUtc), |
| 351 | timeUtc, |
| 352 | region, |
| 353 | timeUrl, |
| 354 | calendarUrl, |
| 355 | }; |
| 356 | |
| 357 | const title = createTitle(templateData).trim(); |
| 358 | const body = createBody(templateData).trim(); |
| 359 | |
| 360 | return {title, labels, body}; |
| 361 | } |
no test coverage detected