MCPcopy Create free account
hub / github.com/ampproject/amphtml / getNextIssueData

Function getNextIssueData

build-system/common/update-session-issues/index.js:304–361  ·  view source on GitHub ↗

* @param {TemplateDef} template * @return {object}

(template)

Source from the content-addressed store, hash-verified

302 * @return {object}
303 */
304function 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}

Callers 1

createScheduledIssueFunction · 0.85

Calls 8

addDaysFunction · 0.85
getRotationFunction · 0.85
isDaylightSavingsUsaFunction · 0.85
leadingZeroFunction · 0.85
timeZFunction · 0.85
getParseableDatetimeUtcFunction · 0.85
createTitleFunction · 0.85
createBodyFunction · 0.85

Tested by

no test coverage detected