How to use ics - 8 common examples

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 opencollective / opencollective-api / server / models / Collective.js View on Github external
description,
          start,
          end,
          location,
          url,
          status: 'CONFIRMED',
          organizer: {
            name: parentCollective.name,
            email: `hello@${parentCollective.slug}.opencollective.com`,
          },
          alarms,
        };
        if (this.location.lat) {
          event.geo = { lat: this.location.lat, lon: this.location.long };
        }
        ics.createEvent(event, (err, res) => {
          if (err) {
            console.error(`Error while generating the ics file for event id ${this.id} (${url})`, err);
          }
          return resolve(res);
        });
      });
    });
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`
    );
github comatory / fb2iCal / lib / services / ics-generator.js View on Github external
return new Promise((resolve, reject) => {
    ics.createEvent(data, (err, value) => {
      if (err) {
        reject(err)
        return
      }

      resolve(value)
    })
  })
}
github opencollective / opencollective-api / server / models / Collective.js View on Github external
description,
          start,
          end,
          location,
          url,
          status: 'CONFIRMED',
          organizer: {
            name: parentCollective.name,
            email: `hello@${parentCollective.slug}.opencollective.com`,
          },
          alarms,
        };
        if (this.location.lat) {
          event.geo = { lat: this.location.lat, lon: this.location.long };
        }
        ics.createEvent(event, (err, res) => {
          if (err) {
            logger.error(`Error while generating the ics file for event id ${this.id} (${url})`, err);
          }
          return resolve(res);
        });
      });
    });
github Kitware / simput / src / solnFactory.js View on Github external
var expectedKeys = ['rho', 'u', 'v', 'w', 'p'];
    expectedKeys.forEach(function(el) {
      soln['ics.' + el] = {
        id: 'ics.ics.' + el,
        value: source[el] !== undefined ? [ source[el].trim() ] : []
      };
    });

    var customIcs = { id: 'ics.ics.custom', value: [] };
    Object.keys(source).forEach(function(el) {
      if (expectedKeys.indexOf(el) !== -1) {
        return;
      }
      customIcs.value.push({ name: el, value: [source[el].trim()] });
    });
    soln['ics.custom'] = customIcs;
  }

  defaults[solnKey] = soln;
  return defaults;
}

ics

iCal (ics) file generator

ISC
Latest version published 2 months ago

Package Health Score

81 / 100
Full package analysis