Add time buffer before and after meetings (Google Calendar)

Hi there,

I am building an automation that when a calendar event is received in a Google Calendar account (A), it creates a new calendar in another Google Calendar account (B).
This is working fine, now I would like to add a buffer (- 15 minutes before meeting starts and + 15 minutes after meeting ends).
In the new “Event Date” and “Event End Date” I can select the original meeting start and end times (e.g. {{steps.trigger.event.start.dateTime}} {{steps.trigger.event.end.dateTime}} but cannot find a way to add time to that variable… is it possible?

Thanks in advance!

Hi @simao.rio

First off, welcome to the Pipedream community. Happy to have you!

You might find use in a library like date-fns to add or subtract time from a given timestamp.

I go over how to use this library in our Pipedream University video here: Use NPM packages in code steps - YouTube

1 Like

thank you so much @pierce !

I guess this is quite basic, but in case it helps someone in the future, this is the code I ended up using (created 2 functions one to add and another to sub):

import { sub, add } from ‘date-fns’;
export default defineComponent({
async run({ steps, $ }) {
const start_date_minus_buffer = add(Date.parse(steps.trigger.event.end.dateTime), {minutes: 15})
return start_date_minus_buffer
},
})

1 Like

Hi there! My workflow needs to have a trigger in which I create an event in my Google calendar with a specific title. The steps that are triggered are creating Google Calendar events and Google Tasks entries, which need to be on different dates or times than the original trigger event, some before and some after. I have been able to start creating my workflow, but please forgive me in advance for not being well versed in code. I can add the {{steps.trigger.event.start.dateTime}} from the trigger to the due date for the event or task, but I don’t know how to add the instruction code to the due date that will cause the date of the step to be before or after the original event date. I would appreciate your help with this!