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,
|
IDataObject, NodeApiError,
|
||||||
} from 'n8n-workflow';
|
} 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(
|
export async function todoistApiRequest(
|
||||||
this:
|
this:
|
||||||
| IHookFunctions
|
| IHookFunctions
|
||||||
|
|
|
@ -13,6 +13,7 @@ import {
|
||||||
|
|
||||||
import {
|
import {
|
||||||
todoistApiRequest,
|
todoistApiRequest,
|
||||||
|
FormatDueDatetime,
|
||||||
} from './GenericFunctions';
|
} from './GenericFunctions';
|
||||||
|
|
||||||
interface IBodyCreateTask {
|
interface IBodyCreateTask {
|
||||||
|
@ -276,6 +277,13 @@ export class Todoist implements INodeType {
|
||||||
default: '',
|
default: '',
|
||||||
description: 'Human defined task due date (ex.: “next Monday”, “Tomorrow”). Value is set using local (not UTC) time.',
|
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',
|
displayName: 'Priority',
|
||||||
name: 'priority',
|
name: 'priority',
|
||||||
|
@ -449,6 +457,13 @@ export class Todoist implements INodeType {
|
||||||
default: '',
|
default: '',
|
||||||
description: 'Human defined task due date (ex.: “next Monday”, “Tomorrow”). Value is set using local (not UTC) time.',
|
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',
|
displayName: 'Labels',
|
||||||
name: 'labels',
|
name: 'labels',
|
||||||
|
@ -573,13 +588,17 @@ export class Todoist implements INodeType {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (options.dueDateTime) {
|
if (options.dueDateTime) {
|
||||||
body.due_datetime = options.dueDateTime as string;
|
body.due_datetime = FormatDueDatetime(options.dueDateTime as string);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (options.dueString) {
|
if (options.dueString) {
|
||||||
body.due_string = options.dueString as string;
|
body.due_string = options.dueString as string;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (options.dueLang) {
|
||||||
|
body.due_lang = options.dueLang as string;
|
||||||
|
}
|
||||||
|
|
||||||
if (labels !== undefined && labels.length !== 0) {
|
if (labels !== undefined && labels.length !== 0) {
|
||||||
body.label_ids = labels;
|
body.label_ids = labels;
|
||||||
}
|
}
|
||||||
|
@ -670,13 +689,17 @@ export class Todoist implements INodeType {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (updateFields.dueDateTime) {
|
if (updateFields.dueDateTime) {
|
||||||
body.due_datetime = updateFields.dueDateTime as string;
|
body.due_datetime = FormatDueDatetime(updateFields.dueDateTime as string);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (updateFields.dueString) {
|
if (updateFields.dueString) {
|
||||||
body.due_string = updateFields.dueString as string;
|
body.due_string = updateFields.dueString as string;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (updateFields.dueLang) {
|
||||||
|
body.due_lang = updateFields.dueLang as string;
|
||||||
|
}
|
||||||
|
|
||||||
if (updateFields.labels !== undefined &&
|
if (updateFields.labels !== undefined &&
|
||||||
Array.isArray(updateFields.labels) &&
|
Array.isArray(updateFields.labels) &&
|
||||||
updateFields.labels.length !== 0) {
|
updateFields.labels.length !== 0) {
|
||||||
|
|
Loading…
Reference in a new issue