Add support for moment types to If Node

This commit is contained in:
Jan Oberhauser 2021-10-26 11:32:54 -05:00
parent 37930057d8
commit 119989bc37

View file

@ -1,3 +1,4 @@
import moment = require('moment');
import { IExecuteFunctions } from 'n8n-core'; import { IExecuteFunctions } from 'n8n-core';
import { import {
INodeExecutionData, INodeExecutionData,
@ -333,6 +334,8 @@ export class If implements INodeType {
returnValue = new Date(value).getTime(); returnValue = new Date(value).getTime();
} else if (typeof value === 'number') { } else if (typeof value === 'number') {
returnValue = value; returnValue = value;
} if (moment.isMoment(value)) {
returnValue = value.unix();
} if ((value as unknown as object) instanceof Date) { } if ((value as unknown as object) instanceof Date) {
returnValue = (value as unknown as Date).getTime(); returnValue = (value as unknown as Date).getTime();
} }