Add parameter include time when setting field type date on Notion node (#1879)

*  Add parameter include time when setting field type date

Fixes issue #1878

* Fix issue with date format
This commit is contained in:
Ricardo Espinoza
2021-06-12 12:06:47 -04:00
committed by GitHub
parent b2e0bcea16
commit d095588ac7
3 changed files with 39 additions and 5 deletions

View File

@@ -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 {