fix(Date & Time Node): Convert luxon DateTime object to ISO

This commit is contained in:
Michael Kret
2023-04-05 13:05:51 +03:00
committed by GitHub
parent f8b9b8b680
commit 77106520c8
2 changed files with 174 additions and 1 deletions

View File

@@ -1,4 +1,5 @@
import type {
IDataObject,
IExecuteFunctions,
ILoadOptionsFunctions,
INodeExecutionData,
@@ -6,12 +7,15 @@ import type {
INodeType,
INodeTypeDescription,
} from 'n8n-workflow';
import { deepCopy, NodeOperationError } from 'n8n-workflow';
import set from 'lodash.set';
import moment from 'moment-timezone';
import { DateTime as LuxonDateTime } from 'luxon';
function parseDateByFormat(this: IExecuteFunctions, value: string, fromFormat: string) {
const date = moment(value, fromFormat, true);
if (moment(date).isValid()) return date;
@@ -411,12 +415,16 @@ export class DateTime implements INodeType {
item = items[i];
if (action === 'format') {
const currentDate = this.getNodeParameter('value', i) as string;
let currentDate = this.getNodeParameter('value', i) as string;
const dataPropertyName = this.getNodeParameter('dataPropertyName', i);
const toFormat = this.getNodeParameter('toFormat', i) as string;
const options = this.getNodeParameter('options', i);
let newDate;
if ((currentDate as unknown as IDataObject) instanceof LuxonDateTime) {
currentDate = (currentDate as unknown as LuxonDateTime).toISO();
}
if (currentDate === undefined) {
continue;
}