diff --git a/packages/nodes-base/nodes/Todoist/GenericFunctions.ts b/packages/nodes-base/nodes/Todoist/GenericFunctions.ts index bd09118daee98..a8658a42db122 100644 --- a/packages/nodes-base/nodes/Todoist/GenericFunctions.ts +++ b/packages/nodes-base/nodes/Todoist/GenericFunctions.ts @@ -12,6 +12,12 @@ import { IDataObject, NodeApiError, } from 'n8n-workflow'; +export function FormatDueDatetime(ISOString: string): string { + // Assuming that the problem with incorrect date format was caused by milliseconds + // Replacing the last 5 characters of ISO-formatted string with just Z char + return ISOString.replace(new RegExp('.000Z$'), 'Z'); +} + export async function todoistApiRequest( this: | IHookFunctions diff --git a/packages/nodes-base/nodes/Todoist/Todoist.node.ts b/packages/nodes-base/nodes/Todoist/Todoist.node.ts index a4ebc6fe2dc9a..edc5c4fcce374 100644 --- a/packages/nodes-base/nodes/Todoist/Todoist.node.ts +++ b/packages/nodes-base/nodes/Todoist/Todoist.node.ts @@ -13,6 +13,7 @@ import { import { todoistApiRequest, + FormatDueDatetime, } from './GenericFunctions'; interface IBodyCreateTask { @@ -276,6 +277,13 @@ export class Todoist implements INodeType { default: '', description: 'Human defined task due date (ex.: “next Monday”, “Tomorrow”). Value is set using local (not UTC) time.', }, + { + displayName: 'Due String Locale', + name: 'dueLang', + type: 'string', + default: '', + description: '2-letter code specifying language in case due_string is not written in English.', + }, { displayName: 'Priority', name: 'priority', @@ -357,7 +365,7 @@ export class Todoist implements INodeType { ], operation: [ 'getAll', - ], + ], }, }, options: [ @@ -449,6 +457,13 @@ export class Todoist implements INodeType { default: '', description: 'Human defined task due date (ex.: “next Monday”, “Tomorrow”). Value is set using local (not UTC) time.', }, + { + displayName: 'Due String Locale', + name: 'dueLang', + type: 'string', + default: '', + description: '2-letter code specifying language in case due_string is not written in English.', + }, { displayName: 'Labels', name: 'labels', @@ -573,13 +588,17 @@ export class Todoist implements INodeType { } if (options.dueDateTime) { - body.due_datetime = options.dueDateTime as string; + body.due_datetime = FormatDueDatetime(options.dueDateTime as string); } if (options.dueString) { body.due_string = options.dueString as string; } + if (options.dueLang) { + body.due_lang = options.dueLang as string; + } + if (labels !== undefined && labels.length !== 0) { body.label_ids = labels; } @@ -670,13 +689,17 @@ export class Todoist implements INodeType { } if (updateFields.dueDateTime) { - body.due_datetime = updateFields.dueDateTime as string; + body.due_datetime = FormatDueDatetime(updateFields.dueDateTime as string); } if (updateFields.dueString) { body.due_string = updateFields.dueString as string; } + if (updateFields.dueLang) { + body.due_lang = updateFields.dueLang as string; + } + if (updateFields.labels !== undefined && Array.isArray(updateFields.labels) && updateFields.labels.length !== 0) {