How to use ical-generator - 5 common examples

To help you get started, we’ve selected a few ical-generator examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github flow-typed / flow-typed / definitions / npm / ical-generator_v0.2.x / test_ical-generator-v0.2.js View on Github external
// @flow
import ical from 'ical-generator';

const calendar = ical({
  domain: 'foo',
});
ical({
  name: '',
});

// $ExpectError - domain should be string
ical({ domain: 1 });

calendar.clear();
const event = calendar.createEvent();
// $ExpectError
calendar.createEvent('event');
(calendar.domain(): string)

// $ExpectError
github atulmy / hire-smart / code / api / src / modules / interview / mutation.js View on Github external
.populate('interviewerId')
    .populate('userId')

  const date = moment(interviewDetails.dateTime).format(`${ params.date.format.nice.date }, ${ params.date.format.nice.time }`)

  if(invite) {
    const mode = params.interview.modes.filter(item => item.key === interviewDetails.mode)[0].name
    const subjectAction = {
      invite: 'Invitation',
      update: 'Updated',
      remind: 'Reminder',
    }[type]
    const subject = `${ interviewDetails.organizationId.name } Interview ${ subjectAction } - ${ date }`

    // Calendar
    const calendar = ical({
      method: 'publish',
      domain: interviewDetails.organizationId.domain,
      name: subject
    })
    const event = calendar.createEvent({
      domain: interviewDetails.organizationId.domain,
      start: moment(interviewDetails.dateTime).toDate(),
      end: moment(interviewDetails.dateTime).add(1, 'hour').toDate(),
      summary: subject,
      location: mode,
      description: interviewDetails.note
    })
    event.organizer({
      name: auth.user.name,
      email: auth.user.email,
    })
github MuddCreates / hyperschedule / src / util / export.jsx View on Github external
export const exportICS = (courses, keys) => {
  const cal = ical();

  for (const key of keys) {
    const course = courses.get(key);
    for (const slot of course.get("schedule")) {
      const listedStartDay = new Date(course.get("startDate"));
      const listedStartWeekday = listedStartDay.getDay();
      const listedEndDay = new Date(course.get("endDate"));

      // Determine the first day of class. We want to pick the
      // weekday that occurs the soonest after (possibly on the same
      // day as) the listed start date.
      let weekdayDifference = 7;
      for (const weekday of slot.get("days")) {
        const possibleStartWeekday = dayIndex[weekday];
        const possibleWeekdayDifference =
          (possibleStartWeekday - listedStartWeekday) % 7;
github ReactFinland / graphql-api / server / routes / calendar.ts View on Github external
function calendar({
  filename,
  title,
  schedules,
}: {
  filename: string;
  title: string;
  schedules: Schedule[];
}) {
  const timezone = "+03:00"; // EEST
  const domain = "https://react-finland.fi";
  const cal = ical({ domain, name: title });

  if (Array.isArray(schedules)) {
    schedules.forEach(({ day, intervals }) => {
      intervals.forEach(({ begin, end, sessions }) => {
        sessions.forEach(({ title: summary, description, location }) => {
          cal.createEvent({
            start: new Date(`${day}T${begin}${timezone}`),
            end: new Date(`${day}T${end}${timezone}`),
            summary,
            description,
            location: resolveLocation(location),
            url: domain,
          });
        });
      });
    });
github nusmodifications / nusmods / v3 / src / js / actions / export.js View on Github external
export function downloadAsIcal(
  semester: Semester,
  timetable: SemTimetableConfigWithLessons,
  moduleData: { [ModuleCode]: Module },
) {
  const events = iCalForTimetable(semester, timetable, moduleData);
  const cal = ical({
    domain: 'nusmods.com',
    prodId: '//NUSMods//NUSMods//EN',
    events,
  });

  const blob = new Blob([cal.toString()], { type: 'text/plain' });
  downloadUrl(blob, 'nusmods_calendar.ics');

  return {
    type: DOWNLOAD_AS_ICAL,
    payload: cal.toString(),
  };
}

ical-generator

ical-generator is a small piece of code which generates ical calendar files

MIT
Latest version published 1 month ago

Package Health Score

80 / 100
Full package analysis

Popular ical-generator functions