diff --git a/packages/nodes-base/nodes/Notion/DatabasePageDescription.ts b/packages/nodes-base/nodes/Notion/DatabasePageDescription.ts index 5ef0485fb9..3a868247e7 100644 --- a/packages/nodes-base/nodes/Notion/DatabasePageDescription.ts +++ b/packages/nodes-base/nodes/Notion/DatabasePageDescription.ts @@ -339,6 +339,20 @@ export const databasePageFields = [ default: false, description: 'Weather or not you want to define a date range.', }, + { + displayName: 'Include Time', + name: 'includeTime', + displayOptions: { + show: { + type: [ + 'date', + ], + }, + }, + type: 'boolean', + default: true, + description: 'Weather or not to include the time in the date.', + }, { displayName: 'Date', name: 'date', @@ -685,6 +699,20 @@ export const databasePageFields = [ default: false, description: 'Weather or not you want to define a date range.', }, + { + displayName: 'Include Time', + name: 'includeTime', + displayOptions: { + show: { + type: [ + 'date', + ], + }, + }, + type: 'boolean', + default: true, + description: 'Weather or not to include the time in the date.', + }, { displayName: 'Date', name: 'date', diff --git a/packages/nodes-base/nodes/Notion/GenericFunctions.ts b/packages/nodes-base/nodes/Notion/GenericFunctions.ts index 83b5cf1dfe..661241df72 100644 --- a/packages/nodes-base/nodes/Notion/GenericFunctions.ts +++ b/packages/nodes-base/nodes/Notion/GenericFunctions.ts @@ -270,15 +270,14 @@ function getPropertyKeyValue(value: any, type: string, timezone: string) { }; break; case 'date': - //&& value.dateStart !== 'Invalid date' && value.dateEnd !== 'Invalid date' + const format = getDateFormat(value.includeTime); if (value.range === true) { result = { - type: 'date', date: { start: moment.tz(value.dateStart, timezone).utc().format(), end: moment.tz(value.dateEnd, timezone).utc().format() }, + type: 'date', date: { start: moment.tz(value.dateStart, timezone).format(format), end: moment.tz(value.dateEnd, timezone).format(format) }, }; - //if (value.date !== 'Invalid date') } else { result = { - type: 'date', date: { start: moment.tz(value.date, timezone).utc().format(), end: null }, + type: 'date', date: { start: moment.tz(value.date, timezone).format(format), end: null }, }; } break; @@ -287,6 +286,13 @@ function getPropertyKeyValue(value: any, type: string, timezone: string) { return result; } +function getDateFormat(includeTime: boolean) { + if (includeTime === false) { + return 'yyyy-MM-DD'; + } + return ''; +} + function getNameAndType(key: string) { const [name, type] = key.split('|'); return { diff --git a/packages/nodes-base/nodes/Notion/Notion.node.ts b/packages/nodes-base/nodes/Notion/Notion.node.ts index 5ae5325d77..bce3672730 100644 --- a/packages/nodes-base/nodes/Notion/Notion.node.ts +++ b/packages/nodes-base/nodes/Notion/Notion.node.ts @@ -158,7 +158,7 @@ export class Notion implements INodeType { const databases = await notionApiRequestAllItems.call(this, 'results', 'POST', `/search`, body); for (const database of databases) { returnData.push({ - name: database.title[0].plain_text, + name: database.title[0]?.plain_text || database.id, value: database.id, }); }