Fix Format date operation

This commit is contained in:
agobrech 2023-04-06 17:28:13 +02:00
parent e67d2d5854
commit 951ef699f8
2 changed files with 2 additions and 4 deletions

View file

@ -122,11 +122,11 @@ export class DateTimeV2 implements INodeType {
if (format === 'custom') { if (format === 'custom') {
const customFormat = this.getNodeParameter('customFormat', i) as string; const customFormat = this.getNodeParameter('customFormat', i) as string;
responseData.push({ responseData.push({
[outputFieldName]: DateTime.fromFormat(dateLuxon.toISO(), customFormat), [outputFieldName]: dateLuxon.toFormat(customFormat),
}); });
} else { } else {
responseData.push({ responseData.push({
[outputFieldName]: DateTime.fromFormat(dateLuxon.toISO(), format), [outputFieldName]: dateLuxon.toFormat(format),
}); });
} }
} else if (operation === 'roundDate') { } else if (operation === 'roundDate') {

View file

@ -7,12 +7,10 @@ export function parseDate(this: IExecuteFunctions, date: string | DateTime, time
let parsedDate; let parsedDate;
if (date instanceof DateTime) { if (date instanceof DateTime) {
console.log('date is a DateTime object');
parsedDate = date; parsedDate = date;
} else { } else {
parsedDate = DateTime.fromISO(moment.tz(date, timezone).toISOString()); parsedDate = DateTime.fromISO(moment.tz(date, timezone).toISOString());
if (parsedDate.invalidReason === 'unparsable') { if (parsedDate.invalidReason === 'unparsable') {
console.log(parsedDate.invalidReason);
throw new NodeOperationError(this.getNode(), 'Invalid date format'); throw new NodeOperationError(this.getNode(), 'Invalid date format');
} }
} }