How to use the ics.createEvents function in ics

To help you get started, we’ve selected a few ics 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 softwarecrafters / website / scripts / build-conferences-ics.js View on Github external
const ics = require("ics");

const conferenceFiles = glob.sync(
  path.resolve(__dirname, "../conferences/") + "/*.json"
);

// validate

// write to conferences.json
const conferences = conferenceFiles
  .map(file => {
    return JSON.parse(fs.readFileSync(file).toString());
  })
  .filter(conference => conference["next-date"] != null);

const { error, value } = ics.createEvents(
  conferences.map(conference => {
    const start = conference["next-date"]["start"].split(/-/).map(Number);
    const end = conference["next-date"]["end"].split(/-/).map(Number);

    if(conference["next-date"]["start"] === conference["next-date"]["end"]) {
      // Yeah, that's how ICS works.
      end[2]++;
    }

    const geo = {
      lat: conference.location.coordinates[1],
      lon: conference.location.coordinates[0]
    }

    return {
      title: conference.name,
github dat-land / comm-comm / website / get-meetings.js View on Github external
assignee,
          markdown: issue.body,
          html: (await markdowner(issue.body)).content,
          url: issue.html_url
        }
      })
  ))
    .filter(issue => issue.time && issue.assignee) // Skipping issues without time or assignee (not confirmed)
    .sort((a, b) => {
      if (a.time > b.time) return 1
      if (a.time < b.time) return -1
      return 0
    })
  await fs.writeFile(`meetings.json`, JSON.stringify({ meetings }, null, 2))

  const cal = createEvents(
    meetings.map(meeting => {
      const time = meeting.time.tz('utc')
      return {
        start: [time.year(), time.month() + 1, time.date(), time.hour(), time.minute()],
        duration: { hours: 1 },
        uid: meeting.uid,
        timestamp: meeting.updated_at.utc().format('YYYYMMDDTHHMMSS') + 'Z',
        startType: 'utc',
        title: meeting.title,
        description: meeting.markdown,
        alarms: [
          { action: 'display', description: 'One hour until DAT comm-comm meeting', trigger: { hours: 1, minutes: 0, before: true } }
        ],
        url: meeting.url
      }
    })
github codebuddies / codebuddies / server / i-cal-feed.js View on Github external
.utc(hangout.start)
          .format("YYYY-M-D-H-m")
          .split("-"),
        end: moment
          .utc(hangout.start)
          .format("YYYY-M-D-H-m")
          .split("-"),
        organizer: {
          name: hangout.host && hangout.host.name,
          email: "noreply@codebuddies.org"
        },
        method: "REQUEST"
      };
    });

    const { error, value } = ics.createEvents(events);

    if (error) {
      console.log("iCalFeed.handleRequest Error:", error);
      res.statusCode = 500;
      return res.end();
    }

    res.statusCode = 200;
    res.setHeader("Content-type", "text/calendar;charset=UTF-8");
    res.write(value);
    res.end();
  }
};
github bazzite / statusfy / packages / @statusfy / core / lib / content / calendar.js View on Github external
});

  incidents.forEach(i => {
    const id = host ? { uid: `${i.id}@${host}` } : {};

    events.push({
      title: i.title,
      description: i.description,
      start: extractDate(dates.parse(i.scheduled)),
      end: extractDate(dates.parse(i.scheduled).add(i.duration, "minute")),
      productId,
      ...id
    });
  });

  const calendar = ics.createEvents(events);
  const { error } = calendar;
  let { value } = calendar;

  if (error) {
    throw new Error(error);
  } else {
    if (!value) {
      value = `BEGIN:VCALENDAR\nVERSION:2.0\nPRODID:${productId}\nEND:VCALENDAR`;
    }

    value = value.replace(
      `PRODID:${productId}`,
      `PRODID:${productId}\nNAME:${siteConfig.title}\nX-WR-CALNAME:${
        siteConfig.title
      }\nTIMEZONE-ID:UTC\nX-WR-TIMEZONE:UTC`
    );

ics

iCal (ics) file generator

ISC
Latest version published 5 months ago

Package Health Score

75 / 100
Full package analysis