How to use the node-ical.parseICS function in node-ical

To help you get started, we’ve selected a few node-ical 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 sedenardi / node-caldav-adapter / src / common / parseBody.js View on Github external
module.exports = async function(ctx) {
  ctx.request.body = await raw(ctx.req, {
    encoding: true,
    limit: '1mb' // practical
  });

  if (ctx.request.type.includes('xml')) {
    ctx.request.xml = new DOMParser().parseFromString(ctx.request.body);
  } else if (ctx.request.type === 'text/calendar') {
    ctx.request.ical = ical.parseICS(ctx.request.body);
  }
};
github iobroker-community-adapters / ioBroker.ical / main.js View on Github external
getICal(urlOrFile, user, pass, sslignore, calName, (err, _data) => {
        if (err || !_data) {
            adapter.log.warn('Error reading "' + urlOrFile + '": ' + err);
            cb(calName);
            return;
        }

        adapter.log.debug('File read successfully ' + urlOrFile);

        let data;
        try {
            data = ical.parseICS(_data, (err, data) => {
                if (data) {
                    adapter.log.info('processing URL: ' + calName + ' ' + urlOrFile);
                    adapter.log.debug(JSON.stringify(data));
                    const realnow    = new Date();
                    const today      = new Date();
                    today.setHours(0, 0, 0, 0);
                    const endpreview = new Date();
                    endpreview.setDate(endpreview.getDate() + parseInt(adapter.config.daysPreview, 10));

                    const now2 = new Date();

                    // clear time
                    now2.setHours(0, 0, 0, 0);

                    setImmediate(() =>
                        processData(data, realnow, today, endpreview, now2, calName, filter, cb));
github awslabs / aws-delivlib / change-control-lambda / lib / time-window.ts View on Github external
export function shouldBlockPipeline(icalData: string | Buffer, now = new Date(), advanceMarginSec = 3600): CalendarEvent | undefined {
  const events: Events = ical.parseICS(icalData.toString('utf8'));
  const blocks = containingEventsWithMargin(events, now, advanceMarginSec);
  return blocks.length > 0 ? blocks[0] : undefined;
}

node-ical

NodeJS class for parsing iCalendar/ICS files

Apache-2.0
Latest version published 3 months ago

Package Health Score

84 / 100
Full package analysis