node-ical-toolkit icon indicating copy to clipboard operation
node-ical-toolkit copied to clipboard

Time show incorrectly once deployed. Mayb timezone wrong?

Open Mike-Van opened this issue 4 years ago • 0 comments

Hello, im using this package to build a simple email notification with calendar event. The problem is in local serverless development, the time sent with calendar event is correct. but once i deployed serverless app. somehow the calendar parsed is incorrect. generally 8 hours ahead of my specified time. Here's the code where i build the calendar event.

const createCalendarEvent = data => {
  const { organizer = {}, date, type = 'note', note = '', time, attendees } = data;

  let builder = icalToolkit.createIcsFileBuilder()

  builder.spacers = true; 
  builder.NEWLINE_CHAR = '\r\n'; 
  builder.throwError = false; 
  builder.ignoreTZIDMismatch = true; 
   
  builder.calname = 'CRM Web Activities';
  builder.timezone = 'Asia/Bangkok';
  builder.tzid = 'Asia/Bangkok';
  builder.method = 'REQUEST';

  builder.events.push({
    start: new Date(`${date} ${time}`),
    end: new Date(`${date} ${time}`),
    summary: `New ${type}.`,
    description: note,
    organizer: {
      name: organizer.name,
      email: organizer.email
    },
    attendees: attendees.map(user => { return { name: user.name, email: user.email } })
  });

  const response = {
    alternatives: [{
      contentType: 'text/calendar; charset="utf-8"; method=REQUEST',
      content: builder.toString()
    }]
  };

  return response;
}

Mike-Van avatar Sep 23 '19 03:09 Mike-Van