mirror of
https://github.com/Abdulazizzn/n8n-enterprise-unlocked.git
synced 2025-12-17 10:02:05 +00:00
fix(Date & Time Node): Convert luxon DateTime object to ISO
This commit is contained in:
@@ -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;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user