mirror of
https://github.com/n8n-io/n8n.git
synced 2024-11-10 14:44:05 -08:00
🐛 Fix due_datetime formatting on Todoist (#2491)
* Fixed due_datetime formatting Signed-off-by: Ivan Lebedev <lisgml@gmail.com> * Option to specify due_string language Signed-off-by: Ivan Lebedev <lisgml@gmail.com> * Removed debug imports Signed-off-by: Ivan Lebedev <lisgml@gmail.com>
This commit is contained in:
parent
d6c7528420
commit
6a2d970ea8
|
@ -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
|
||||
|
|
|
@ -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',
|
||||
|
@ -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) {
|
||||
|
|
Loading…
Reference in a new issue