This topic was automatically generated from Slack. You can find the original thread here.
how can I resolve a known issue with the date defaulting to UTC.
I set up a basic one-way sync using pipedream where Notion tasks are pushed to Todoist. It works except the time is messed up.
The timezone Notion is set to GMT+8, and the timezone in Todoist is set to GMT+8.
When the task is pushed, the Todoist adds ANOTHER 8 hours (I presume it ignores that the timezone is already set to GMT+8).
Anyway, I am trying to figure out how to add a step in Pipedream to deduct hours before pushing to Todoist which will offset the 8 hours added. I also noticed that the timezone in the trigger step keeps defaulting back to UTC event when I change it to GMT+8.
To address the issue with the timezone defaulting to UTC and the additional 8 hours being added to your Todoist tasks, you can add a step in your Pipedream workflow to adjust the time before pushing the task to Todoist. This step will involve manipulating the date to subtract the extra hours. Here’s an example of how you might adjust the date in a Node.js code step: import { axios } from "@pipedream/platform"; export default defineComponent({ props: { notion: { type: "app", app: "notion", }, todoist: { type: "app", app: "todoist", }, }, async run({ steps, $ }) { // Assuming you have the date from Notion in a variable called `notionDate` // and it's in ISO 8601 format (e.g., "2023-03-26T15:00:00Z") let notionDate = steps.trigger.event.body.date; // Replace with the actual path to the date in the trigger data // Convert the Notion date to a JavaScript Date object let date = new Date(notionDate); // Subtract 8 hours from the date to offset the additional time added by Todoist date.setHours(date.getHours() - 8); // Convert the adjusted date back to ISO 8601 format let adjustedDate = date.toISOString(); // Now you can use `adjustedDate` when creating the task in Todoist // Replace the URL and body with the actual API endpoint and payload for creating a task in Todoist return await axios($, { method: "POST", url: `https://api.todoist.com/rest/v1/tasks`, headers: { Authorization: `Bearer ${this.todoist.$auth.oauth_access_token}`, }, data: { // ... other task data due_date: adjustedDate, // Use the adjusted date here }, }); }, }); Please replace steps.trigger.event.body.date with the actual path to the date in the trigger data from Notion. Also, replace the Todoist API endpoint URL and payload with the correct values for creating a task. Regarding the timezone issue in the trigger step, if you’re unable to maintain the GMT+8 setting, you may want to reach out to