first commit
Security: Sync from Public / sync-from-public (push) Has been cancelled
Test: Benchmark Nightly / build (push) Has been cancelled
Test: Benchmark Nightly / Notify Cats on failure (push) Has been cancelled
CI: Python / Checks (push) Has been cancelled
Test: Evals Python / Workflow Comparison Python (push) Has been cancelled
Util: Check Docs URLs / check-docs-urls (push) Has been cancelled
Test: Visual Storybook / Cloudflare Pages (push) Has been cancelled
Test: E2E Performance / build-and-test-performance (push) Has been cancelled
Test: Workflows Nightly / Run Workflow Tests (push) Has been cancelled
Util: Cleanup CI Docker Images / Delete stale CI images (push) Has been cancelled
Test: Benchmark Destroy Env / build (push) Has been cancelled
Util: Update Node Popularity / update-popularity (push) Has been cancelled
Test: E2E Coverage Weekly / Coverage Tests (push) Has been cancelled
Security: Sync from Public / sync-from-public (push) Has been cancelled
Test: Benchmark Nightly / build (push) Has been cancelled
Test: Benchmark Nightly / Notify Cats on failure (push) Has been cancelled
CI: Python / Checks (push) Has been cancelled
Test: Evals Python / Workflow Comparison Python (push) Has been cancelled
Util: Check Docs URLs / check-docs-urls (push) Has been cancelled
Test: Visual Storybook / Cloudflare Pages (push) Has been cancelled
Test: E2E Performance / build-and-test-performance (push) Has been cancelled
Test: Workflows Nightly / Run Workflow Tests (push) Has been cancelled
Util: Cleanup CI Docker Images / Delete stale CI images (push) Has been cancelled
Test: Benchmark Destroy Env / build (push) Has been cancelled
Util: Update Node Popularity / update-popularity (push) Has been cancelled
Test: E2E Coverage Weekly / Coverage Tests (push) Has been cancelled
This commit is contained in:
@@ -0,0 +1,28 @@
|
||||
{
|
||||
"node": "n8n-nodes-base.dateTime",
|
||||
"nodeVersion": "1.0",
|
||||
"codexVersion": "1.0",
|
||||
"categories": ["Core Nodes"],
|
||||
"resources": {
|
||||
"primaryDocumentation": [
|
||||
{
|
||||
"url": "https://docs.n8n.io/integrations/builtin/core-nodes/n8n-nodes-base.datetime/"
|
||||
}
|
||||
],
|
||||
"generic": [
|
||||
{
|
||||
"label": "6 e-commerce workflows to power up your Shopify s",
|
||||
"icon": "store",
|
||||
"url": "https://n8n.io/blog/no-code-ecommerce-workflow-automations/"
|
||||
},
|
||||
{
|
||||
"label": "How to get started with CRM automation (with 3 no-code workflow ideas",
|
||||
"icon": "👥",
|
||||
"url": "https://n8n.io/blog/how-to-get-started-with-crm-automation-and-no-code-workflow-ideas/"
|
||||
}
|
||||
]
|
||||
},
|
||||
"subcategories": {
|
||||
"Core Nodes": ["Data Transformation"]
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,27 @@
|
||||
import type { INodeTypeBaseDescription, IVersionedNodeType } from 'n8n-workflow';
|
||||
import { VersionedNodeType } from 'n8n-workflow';
|
||||
|
||||
import { DateTimeV1 } from './V1/DateTimeV1.node';
|
||||
import { DateTimeV2 } from './V2/DateTimeV2.node';
|
||||
|
||||
export class DateTime extends VersionedNodeType {
|
||||
constructor() {
|
||||
const baseDescription: INodeTypeBaseDescription = {
|
||||
displayName: 'Date & Time',
|
||||
name: 'dateTime',
|
||||
icon: 'fa:clock',
|
||||
iconColor: 'green',
|
||||
group: ['transform'],
|
||||
defaultVersion: 2,
|
||||
description: 'Allows you to manipulate date and time values',
|
||||
subtitle: '={{$parameter["action"]}}',
|
||||
};
|
||||
|
||||
const nodeVersions: IVersionedNodeType['nodeVersions'] = {
|
||||
1: new DateTimeV1(baseDescription),
|
||||
2: new DateTimeV2(baseDescription),
|
||||
};
|
||||
|
||||
super(nodeVersions, baseDescription);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,585 @@
|
||||
import set from 'lodash/set';
|
||||
import { DateTime as LuxonDateTime } from 'luxon';
|
||||
import moment from 'moment-timezone';
|
||||
import type {
|
||||
IDataObject,
|
||||
IExecuteFunctions,
|
||||
ILoadOptionsFunctions,
|
||||
INodeExecutionData,
|
||||
INodePropertyOptions,
|
||||
INodeType,
|
||||
INodeTypeBaseDescription,
|
||||
INodeTypeDescription,
|
||||
} from 'n8n-workflow';
|
||||
import { deepCopy, NodeConnectionTypes, NodeOperationError } from 'n8n-workflow';
|
||||
|
||||
function parseDateByFormat(this: IExecuteFunctions, value: string, fromFormat: string) {
|
||||
const date = moment(value, fromFormat, true);
|
||||
if (moment(date).isValid()) return date;
|
||||
|
||||
throw new NodeOperationError(
|
||||
this.getNode(),
|
||||
'Date input cannot be parsed. Please recheck the value and the "From Format" field.',
|
||||
);
|
||||
}
|
||||
|
||||
function getIsoValue(this: IExecuteFunctions, value: string) {
|
||||
try {
|
||||
return new Date(value).toISOString(); // may throw due to unpredictable input
|
||||
} catch (error) {
|
||||
throw new NodeOperationError(
|
||||
this.getNode(),
|
||||
'Unrecognized date input. Please specify a format in the "From Format" field.',
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
function parseDateByDefault(this: IExecuteFunctions, value: string) {
|
||||
const isoValue = getIsoValue.call(this, value);
|
||||
if (moment(isoValue).isValid()) return moment(isoValue);
|
||||
|
||||
throw new NodeOperationError(
|
||||
this.getNode(),
|
||||
'Unrecognized date input. Please specify a format in the "From Format" field.',
|
||||
);
|
||||
}
|
||||
|
||||
const versionDescription: INodeTypeDescription = {
|
||||
displayName: 'Date & Time',
|
||||
name: 'dateTime',
|
||||
icon: 'fa:clock',
|
||||
group: ['transform'],
|
||||
version: 1,
|
||||
description: 'Allows you to manipulate date and time values',
|
||||
subtitle: '={{$parameter["action"]}}',
|
||||
defaults: {
|
||||
name: 'Date & Time',
|
||||
color: '#408000',
|
||||
},
|
||||
inputs: [NodeConnectionTypes.Main],
|
||||
outputs: [NodeConnectionTypes.Main],
|
||||
properties: [
|
||||
{
|
||||
displayName:
|
||||
"More powerful date functionality is available in <a href='https://docs.n8n.io/code/cookbook/luxon/' target='_blank'>expressions</a>,</br> e.g. <code>{{ $now.plus(1, 'week') }}</code>",
|
||||
name: 'noticeDateTime',
|
||||
type: 'notice',
|
||||
default: '',
|
||||
},
|
||||
{
|
||||
displayName: 'Action',
|
||||
name: 'action',
|
||||
type: 'options',
|
||||
options: [
|
||||
{
|
||||
name: 'Calculate a Date',
|
||||
description: 'Add or subtract time from a date',
|
||||
value: 'calculate',
|
||||
action: 'Add or subtract time from a date',
|
||||
},
|
||||
{
|
||||
name: 'Format a Date',
|
||||
description: 'Convert a date to a different format',
|
||||
value: 'format',
|
||||
action: 'Convert a date to a different format',
|
||||
},
|
||||
],
|
||||
default: 'format',
|
||||
},
|
||||
{
|
||||
displayName: 'Value',
|
||||
name: 'value',
|
||||
displayOptions: {
|
||||
show: {
|
||||
action: ['format'],
|
||||
},
|
||||
},
|
||||
type: 'string',
|
||||
default: '',
|
||||
description: 'The value that should be converted',
|
||||
required: true,
|
||||
},
|
||||
{
|
||||
displayName: 'Property Name',
|
||||
name: 'dataPropertyName',
|
||||
type: 'string',
|
||||
default: 'data',
|
||||
required: true,
|
||||
displayOptions: {
|
||||
show: {
|
||||
action: ['format'],
|
||||
},
|
||||
},
|
||||
description: 'Name of the property to which to write the converted date',
|
||||
},
|
||||
{
|
||||
displayName: 'Custom Format',
|
||||
name: 'custom',
|
||||
displayOptions: {
|
||||
show: {
|
||||
action: ['format'],
|
||||
},
|
||||
},
|
||||
type: 'boolean',
|
||||
default: false,
|
||||
description: 'Whether a predefined format should be selected or custom format entered',
|
||||
},
|
||||
{
|
||||
displayName: 'To Format',
|
||||
name: 'toFormat',
|
||||
displayOptions: {
|
||||
show: {
|
||||
action: ['format'],
|
||||
custom: [true],
|
||||
},
|
||||
},
|
||||
type: 'string',
|
||||
default: '',
|
||||
placeholder: 'YYYY-MM-DD',
|
||||
description: 'The format to convert the date to',
|
||||
},
|
||||
{
|
||||
displayName: 'To Format',
|
||||
name: 'toFormat',
|
||||
type: 'options',
|
||||
displayOptions: {
|
||||
show: {
|
||||
action: ['format'],
|
||||
custom: [false],
|
||||
},
|
||||
},
|
||||
// eslint-disable-next-line n8n-nodes-base/node-param-options-type-unsorted-items
|
||||
options: [
|
||||
{
|
||||
name: 'MM/DD/YYYY',
|
||||
value: 'MM/DD/YYYY',
|
||||
description: 'Example: 09/04/1986',
|
||||
},
|
||||
{
|
||||
name: 'YYYY/MM/DD',
|
||||
value: 'YYYY/MM/DD',
|
||||
description: 'Example: 1986/04/09',
|
||||
},
|
||||
{
|
||||
name: 'MMMM DD YYYY',
|
||||
value: 'MMMM DD YYYY',
|
||||
description: 'Example: April 09 1986',
|
||||
},
|
||||
{
|
||||
name: 'MM-DD-YYYY',
|
||||
value: 'MM-DD-YYYY',
|
||||
description: 'Example: 09-04-1986',
|
||||
},
|
||||
{
|
||||
name: 'YYYY-MM-DD',
|
||||
value: 'YYYY-MM-DD',
|
||||
description: 'Example: 1986-04-09',
|
||||
},
|
||||
{
|
||||
name: 'Unix Timestamp',
|
||||
value: 'X',
|
||||
description: 'Example: 513388800.879',
|
||||
},
|
||||
{
|
||||
name: 'Unix Ms Timestamp',
|
||||
value: 'x',
|
||||
description: 'Example: 513388800',
|
||||
},
|
||||
],
|
||||
default: 'MM/DD/YYYY',
|
||||
description: 'The format to convert the date to',
|
||||
},
|
||||
{
|
||||
displayName: 'Options',
|
||||
name: 'options',
|
||||
displayOptions: {
|
||||
show: {
|
||||
action: ['format'],
|
||||
},
|
||||
},
|
||||
type: 'collection',
|
||||
placeholder: 'Add option',
|
||||
default: {},
|
||||
options: [
|
||||
{
|
||||
displayName: 'From Format',
|
||||
name: 'fromFormat',
|
||||
type: 'string',
|
||||
default: '',
|
||||
description: 'In case the input format is not recognized you can provide the format',
|
||||
},
|
||||
{
|
||||
displayName: 'From Timezone Name or ID',
|
||||
name: 'fromTimezone',
|
||||
type: 'options',
|
||||
typeOptions: {
|
||||
loadOptionsMethod: 'getTimezones',
|
||||
},
|
||||
default: 'UTC',
|
||||
description:
|
||||
'The timezone to convert from. Choose from the list, or specify an ID using an <a href="https://docs.n8n.io/code/expressions/">expression</a>.',
|
||||
},
|
||||
{
|
||||
displayName: 'To Timezone Name or ID',
|
||||
name: 'toTimezone',
|
||||
type: 'options',
|
||||
typeOptions: {
|
||||
loadOptionsMethod: 'getTimezones',
|
||||
},
|
||||
default: 'UTC',
|
||||
description:
|
||||
'The timezone to convert to. Choose from the list, or specify an ID using an <a href="https://docs.n8n.io/code/expressions/">expression</a>.',
|
||||
},
|
||||
],
|
||||
},
|
||||
{
|
||||
displayName: 'Date Value',
|
||||
name: 'value',
|
||||
displayOptions: {
|
||||
show: {
|
||||
action: ['calculate'],
|
||||
},
|
||||
},
|
||||
type: 'string',
|
||||
default: '',
|
||||
description: 'The date string or timestamp from which you want to add/subtract time',
|
||||
required: true,
|
||||
},
|
||||
{
|
||||
displayName: 'Operation',
|
||||
name: 'operation',
|
||||
displayOptions: {
|
||||
show: {
|
||||
action: ['calculate'],
|
||||
},
|
||||
},
|
||||
type: 'options',
|
||||
noDataExpression: true,
|
||||
options: [
|
||||
{
|
||||
name: 'Add',
|
||||
value: 'add',
|
||||
description: 'Add time to Date Value',
|
||||
action: 'Add time to Date Value',
|
||||
},
|
||||
{
|
||||
name: 'Subtract',
|
||||
value: 'subtract',
|
||||
description: 'Subtract time from Date Value',
|
||||
action: 'Subtract time from Date Value',
|
||||
},
|
||||
],
|
||||
default: 'add',
|
||||
required: true,
|
||||
},
|
||||
{
|
||||
displayName: 'Duration',
|
||||
name: 'duration',
|
||||
displayOptions: {
|
||||
show: {
|
||||
action: ['calculate'],
|
||||
},
|
||||
},
|
||||
type: 'number',
|
||||
typeOptions: {
|
||||
minValue: 0,
|
||||
},
|
||||
default: 0,
|
||||
required: true,
|
||||
description: 'E.g. enter “10” then select “Days” if you want to add 10 days to Date Value.',
|
||||
},
|
||||
{
|
||||
displayName: 'Time Unit',
|
||||
name: 'timeUnit',
|
||||
description: 'Time unit for Duration parameter above',
|
||||
displayOptions: {
|
||||
show: {
|
||||
action: ['calculate'],
|
||||
},
|
||||
},
|
||||
type: 'options',
|
||||
// eslint-disable-next-line n8n-nodes-base/node-param-options-type-unsorted-items
|
||||
options: [
|
||||
{
|
||||
name: 'Quarters',
|
||||
value: 'quarters',
|
||||
},
|
||||
{
|
||||
name: 'Years',
|
||||
value: 'years',
|
||||
},
|
||||
{
|
||||
name: 'Months',
|
||||
value: 'months',
|
||||
},
|
||||
{
|
||||
name: 'Weeks',
|
||||
value: 'weeks',
|
||||
},
|
||||
{
|
||||
name: 'Days',
|
||||
value: 'days',
|
||||
},
|
||||
{
|
||||
name: 'Hours',
|
||||
value: 'hours',
|
||||
},
|
||||
{
|
||||
name: 'Minutes',
|
||||
value: 'minutes',
|
||||
},
|
||||
{
|
||||
name: 'Seconds',
|
||||
value: 'seconds',
|
||||
},
|
||||
{
|
||||
name: 'Milliseconds',
|
||||
value: 'milliseconds',
|
||||
},
|
||||
],
|
||||
default: 'days',
|
||||
required: true,
|
||||
},
|
||||
{
|
||||
displayName: 'Property Name',
|
||||
name: 'dataPropertyName',
|
||||
type: 'string',
|
||||
default: 'data',
|
||||
required: true,
|
||||
displayOptions: {
|
||||
show: {
|
||||
action: ['calculate'],
|
||||
},
|
||||
},
|
||||
description: 'Name of the output property to which to write the converted date',
|
||||
},
|
||||
{
|
||||
displayName: 'Options',
|
||||
name: 'options',
|
||||
type: 'collection',
|
||||
placeholder: 'Add option',
|
||||
default: {},
|
||||
displayOptions: {
|
||||
show: {
|
||||
action: ['calculate'],
|
||||
},
|
||||
},
|
||||
options: [
|
||||
{
|
||||
displayName: 'From Format',
|
||||
name: 'fromFormat',
|
||||
type: 'string',
|
||||
default: '',
|
||||
description:
|
||||
'Format for parsing the value as a date. If unrecognized, specify the <a href="https://docs.n8n.io/integrations/builtin/core-nodes/n8n-nodes-base.datetime/#faqs">format</a> for the value.',
|
||||
},
|
||||
],
|
||||
},
|
||||
],
|
||||
};
|
||||
|
||||
export class DateTimeV1 implements INodeType {
|
||||
description: INodeTypeDescription;
|
||||
|
||||
constructor(baseDescription: INodeTypeBaseDescription) {
|
||||
this.description = {
|
||||
...baseDescription,
|
||||
...versionDescription,
|
||||
};
|
||||
}
|
||||
|
||||
methods = {
|
||||
loadOptions: {
|
||||
// Get all the timezones to display them to user so that they can
|
||||
// select them easily
|
||||
async getTimezones(this: ILoadOptionsFunctions): Promise<INodePropertyOptions[]> {
|
||||
const returnData: INodePropertyOptions[] = [];
|
||||
for (const timezone of moment.tz.names()) {
|
||||
const timezoneName = timezone;
|
||||
const timezoneId = timezone;
|
||||
returnData.push({
|
||||
name: timezoneName,
|
||||
value: timezoneId,
|
||||
});
|
||||
}
|
||||
return returnData;
|
||||
},
|
||||
},
|
||||
};
|
||||
|
||||
async execute(this: IExecuteFunctions): Promise<INodeExecutionData[][]> {
|
||||
const items = this.getInputData();
|
||||
const length = items.length;
|
||||
const returnData: INodeExecutionData[] = [];
|
||||
|
||||
const workflowTimezone = this.getTimezone();
|
||||
let item: INodeExecutionData;
|
||||
|
||||
for (let i = 0; i < length; i++) {
|
||||
try {
|
||||
const action = this.getNodeParameter('action', 0) as string;
|
||||
item = items[i];
|
||||
|
||||
if (action === 'format') {
|
||||
let currentDate: string | number | LuxonDateTime = 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();
|
||||
}
|
||||
|
||||
// Check if the input is a number
|
||||
if (!Number.isNaN(Number(currentDate))) {
|
||||
//input is a number, convert to number in case it is a string
|
||||
currentDate = Number(currentDate);
|
||||
// check if the number is a timestamp in float format and convert to integer
|
||||
if (!Number.isInteger(currentDate)) {
|
||||
currentDate = currentDate * 1000;
|
||||
}
|
||||
}
|
||||
|
||||
if (currentDate === undefined) {
|
||||
continue;
|
||||
}
|
||||
if (options.fromFormat === undefined && !moment(currentDate).isValid()) {
|
||||
throw new NodeOperationError(
|
||||
this.getNode(),
|
||||
'The date input format could not be recognized. Please set the "From Format" field',
|
||||
{ itemIndex: i },
|
||||
);
|
||||
}
|
||||
|
||||
if (Number.isInteger(currentDate)) {
|
||||
const timestampLengthInMilliseconds1990 = 12;
|
||||
// check if the number is a timestamp in seconds or milliseconds and create a moment object accordingly
|
||||
if (currentDate.toString().length < timestampLengthInMilliseconds1990) {
|
||||
newDate = moment.unix(currentDate as number);
|
||||
} else {
|
||||
newDate = moment(currentDate);
|
||||
}
|
||||
} else {
|
||||
if (options.fromTimezone || options.toTimezone) {
|
||||
const fromTimezone = options.fromTimezone || workflowTimezone;
|
||||
if (options.fromFormat) {
|
||||
newDate = moment.tz(
|
||||
currentDate as string,
|
||||
options.fromFormat as string,
|
||||
fromTimezone as string,
|
||||
);
|
||||
} else {
|
||||
newDate = moment.tz(currentDate, fromTimezone as string);
|
||||
}
|
||||
} else {
|
||||
if (options.fromFormat) {
|
||||
newDate = moment(currentDate, options.fromFormat as string);
|
||||
} else {
|
||||
newDate = moment(currentDate);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (options.toTimezone || options.fromTimezone) {
|
||||
// If either a source or a target timezone got defined the
|
||||
// timezone of the date has to be changed. If a target-timezone
|
||||
// is set use it else fall back to workflow timezone.
|
||||
newDate = newDate.tz((options.toTimezone as string) || workflowTimezone);
|
||||
}
|
||||
|
||||
newDate = newDate.format(toFormat);
|
||||
|
||||
let newItem: INodeExecutionData;
|
||||
if (dataPropertyName.includes('.')) {
|
||||
// Uses dot notation so copy all data
|
||||
newItem = {
|
||||
json: deepCopy(item.json),
|
||||
pairedItem: {
|
||||
item: i,
|
||||
},
|
||||
};
|
||||
} else {
|
||||
// Does not use dot notation so shallow copy is enough
|
||||
newItem = {
|
||||
json: { ...item.json },
|
||||
pairedItem: {
|
||||
item: i,
|
||||
},
|
||||
};
|
||||
}
|
||||
|
||||
if (item.binary !== undefined) {
|
||||
newItem.binary = item.binary;
|
||||
}
|
||||
|
||||
set(newItem, ['json', dataPropertyName], newDate);
|
||||
|
||||
returnData.push(newItem);
|
||||
}
|
||||
|
||||
if (action === 'calculate') {
|
||||
const dateValue = this.getNodeParameter('value', i) as string;
|
||||
const operation = this.getNodeParameter('operation', i) as 'add' | 'subtract';
|
||||
const duration = this.getNodeParameter('duration', i) as number;
|
||||
const timeUnit = this.getNodeParameter('timeUnit', i) as moment.DurationInputArg2;
|
||||
const { fromFormat } = this.getNodeParameter('options', i) as { fromFormat?: string };
|
||||
const dataPropertyName = this.getNodeParameter('dataPropertyName', i);
|
||||
|
||||
const newDate = fromFormat
|
||||
? parseDateByFormat.call(this, dateValue, fromFormat)
|
||||
: parseDateByDefault.call(this, dateValue);
|
||||
|
||||
operation === 'add'
|
||||
? newDate.add(duration, timeUnit).utc().format()
|
||||
: newDate.subtract(duration, timeUnit).utc().format();
|
||||
|
||||
let newItem: INodeExecutionData;
|
||||
if (dataPropertyName.includes('.')) {
|
||||
// Uses dot notation so copy all data
|
||||
newItem = {
|
||||
json: deepCopy(item.json),
|
||||
pairedItem: {
|
||||
item: i,
|
||||
},
|
||||
};
|
||||
} else {
|
||||
// Does not use dot notation so shallow copy is enough
|
||||
newItem = {
|
||||
json: { ...item.json },
|
||||
pairedItem: {
|
||||
item: i,
|
||||
},
|
||||
};
|
||||
}
|
||||
|
||||
if (item.binary !== undefined) {
|
||||
newItem.binary = item.binary;
|
||||
}
|
||||
|
||||
set(newItem, ['json', dataPropertyName], newDate.toISOString());
|
||||
|
||||
returnData.push(newItem);
|
||||
}
|
||||
} catch (error) {
|
||||
if (this.continueOnFail()) {
|
||||
returnData.push({
|
||||
json: {
|
||||
error: error.message,
|
||||
},
|
||||
pairedItem: {
|
||||
item: i,
|
||||
},
|
||||
});
|
||||
continue;
|
||||
}
|
||||
throw error;
|
||||
}
|
||||
}
|
||||
|
||||
return [returnData];
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,120 @@
|
||||
import type { INodeProperties } from 'n8n-workflow';
|
||||
|
||||
import { includeInputFields } from './common.descriptions';
|
||||
|
||||
export const AddToDateDescription: INodeProperties[] = [
|
||||
{
|
||||
displayName:
|
||||
"You can also do this using an expression, e.g. <code>{{your_date.plus(5, 'minutes')}}</code>. <a target='_blank' href='https://docs.n8n.io/code/cookbook/luxon/'>More info</a>",
|
||||
name: 'notice',
|
||||
type: 'notice',
|
||||
default: '',
|
||||
displayOptions: {
|
||||
show: {
|
||||
operation: ['addToDate'],
|
||||
},
|
||||
},
|
||||
},
|
||||
{
|
||||
displayName: 'Date to Add To',
|
||||
name: 'magnitude',
|
||||
type: 'string',
|
||||
description: 'The date that you want to change',
|
||||
default: '',
|
||||
displayOptions: {
|
||||
show: {
|
||||
operation: ['addToDate'],
|
||||
},
|
||||
},
|
||||
required: true,
|
||||
},
|
||||
{
|
||||
displayName: 'Time Unit to Add',
|
||||
name: 'timeUnit',
|
||||
description: 'Time unit for Duration parameter below',
|
||||
displayOptions: {
|
||||
show: {
|
||||
operation: ['addToDate'],
|
||||
},
|
||||
},
|
||||
type: 'options',
|
||||
// eslint-disable-next-line n8n-nodes-base/node-param-options-type-unsorted-items
|
||||
options: [
|
||||
{
|
||||
name: 'Years',
|
||||
value: 'years',
|
||||
},
|
||||
{
|
||||
name: 'Quarters',
|
||||
value: 'quarters',
|
||||
},
|
||||
{
|
||||
name: 'Months',
|
||||
value: 'months',
|
||||
},
|
||||
{
|
||||
name: 'Weeks',
|
||||
value: 'weeks',
|
||||
},
|
||||
{
|
||||
name: 'Days',
|
||||
value: 'days',
|
||||
},
|
||||
{
|
||||
name: 'Hours',
|
||||
value: 'hours',
|
||||
},
|
||||
{
|
||||
name: 'Minutes',
|
||||
value: 'minutes',
|
||||
},
|
||||
{
|
||||
name: 'Seconds',
|
||||
value: 'seconds',
|
||||
},
|
||||
{
|
||||
name: 'Milliseconds',
|
||||
value: 'milliseconds',
|
||||
},
|
||||
],
|
||||
default: 'days',
|
||||
required: true,
|
||||
},
|
||||
{
|
||||
displayName: 'Duration',
|
||||
name: 'duration',
|
||||
type: 'number',
|
||||
description: 'The number of time units to add to the date',
|
||||
default: 0,
|
||||
displayOptions: {
|
||||
show: {
|
||||
operation: ['addToDate'],
|
||||
},
|
||||
},
|
||||
},
|
||||
{
|
||||
displayName: 'Output Field Name',
|
||||
name: 'outputFieldName',
|
||||
type: 'string',
|
||||
default: 'newDate',
|
||||
description: 'Name of the field to put the output in',
|
||||
displayOptions: {
|
||||
show: {
|
||||
operation: ['addToDate'],
|
||||
},
|
||||
},
|
||||
},
|
||||
{
|
||||
displayName: 'Options',
|
||||
name: 'options',
|
||||
type: 'collection',
|
||||
placeholder: 'Add option',
|
||||
displayOptions: {
|
||||
show: {
|
||||
operation: ['addToDate'],
|
||||
},
|
||||
},
|
||||
default: {},
|
||||
options: [includeInputFields],
|
||||
},
|
||||
];
|
||||
@@ -0,0 +1,67 @@
|
||||
import type { INodeProperties } from 'n8n-workflow';
|
||||
|
||||
import { includeInputFields } from './common.descriptions';
|
||||
|
||||
export const CurrentDateDescription: INodeProperties[] = [
|
||||
{
|
||||
displayName:
|
||||
'You can also refer to the current date in n8n expressions by using <code>{{$now}}</code> or <code>{{$today}}</code>. <a target="_blank" href="https://docs.n8n.io/code/cookbook/luxon/">More info</a>',
|
||||
name: 'notice',
|
||||
type: 'notice',
|
||||
default: '',
|
||||
displayOptions: {
|
||||
show: {
|
||||
operation: ['getCurrentDate'],
|
||||
},
|
||||
},
|
||||
},
|
||||
{
|
||||
displayName: 'Include Current Time',
|
||||
name: 'includeTime',
|
||||
type: 'boolean',
|
||||
default: true,
|
||||
// eslint-disable-next-line n8n-nodes-base/node-param-description-boolean-without-whether
|
||||
description: 'When deactivated, the time will be set to midnight',
|
||||
displayOptions: {
|
||||
show: {
|
||||
operation: ['getCurrentDate'],
|
||||
},
|
||||
},
|
||||
},
|
||||
{
|
||||
displayName: 'Output Field Name',
|
||||
name: 'outputFieldName',
|
||||
type: 'string',
|
||||
default: 'currentDate',
|
||||
description: 'Name of the field to put the output in',
|
||||
displayOptions: {
|
||||
show: {
|
||||
operation: ['getCurrentDate'],
|
||||
},
|
||||
},
|
||||
},
|
||||
{
|
||||
displayName: 'Options',
|
||||
name: 'options',
|
||||
type: 'collection',
|
||||
placeholder: 'Add option',
|
||||
displayOptions: {
|
||||
show: {
|
||||
operation: ['getCurrentDate'],
|
||||
},
|
||||
},
|
||||
default: {},
|
||||
options: [
|
||||
includeInputFields,
|
||||
{
|
||||
displayName: 'Timezone',
|
||||
name: 'timezone',
|
||||
type: 'string',
|
||||
placeholder: 'America/New_York',
|
||||
default: '',
|
||||
description:
|
||||
'The timezone to use. If not set, the timezone of the n8n instance will be used. Use ‘GMT’ for +00:00 timezone.',
|
||||
},
|
||||
],
|
||||
},
|
||||
];
|
||||
@@ -0,0 +1,231 @@
|
||||
import type { DateTimeUnit, DurationUnit } from 'luxon';
|
||||
import { DateTime } from 'luxon';
|
||||
import { NodeConnectionTypes, NodeOperationError } from 'n8n-workflow';
|
||||
import type {
|
||||
IExecuteFunctions,
|
||||
INodeExecutionData,
|
||||
INodeType,
|
||||
INodeTypeBaseDescription,
|
||||
INodeTypeDescription,
|
||||
} from 'n8n-workflow';
|
||||
|
||||
import { AddToDateDescription } from './AddToDateDescription';
|
||||
import { CurrentDateDescription } from './CurrentDateDescription';
|
||||
import { ExtractDateDescription } from './ExtractDateDescription';
|
||||
import { FormatDateDescription } from './FormatDateDescription';
|
||||
import { parseDate } from './GenericFunctions';
|
||||
import { GetTimeBetweenDatesDescription } from './GetTimeBetweenDates';
|
||||
import { RoundDateDescription } from './RoundDateDescription';
|
||||
import { SubtractFromDateDescription } from './SubtractFromDateDescription';
|
||||
|
||||
export class DateTimeV2 implements INodeType {
|
||||
description: INodeTypeDescription;
|
||||
|
||||
constructor(baseDescription: INodeTypeBaseDescription) {
|
||||
this.description = {
|
||||
...baseDescription,
|
||||
version: 2,
|
||||
defaults: {
|
||||
name: 'Date & Time',
|
||||
color: '#408000',
|
||||
},
|
||||
usableAsTool: true,
|
||||
inputs: [NodeConnectionTypes.Main],
|
||||
outputs: [NodeConnectionTypes.Main],
|
||||
description: 'Manipulate date and time values',
|
||||
properties: [
|
||||
{
|
||||
displayName: 'Operation',
|
||||
name: 'operation',
|
||||
type: 'options',
|
||||
noDataExpression: true,
|
||||
options: [
|
||||
{
|
||||
name: 'Add to a Date',
|
||||
value: 'addToDate',
|
||||
},
|
||||
{
|
||||
name: 'Extract Part of a Date',
|
||||
value: 'extractDate',
|
||||
},
|
||||
{
|
||||
name: 'Format a Date',
|
||||
value: 'formatDate',
|
||||
},
|
||||
{
|
||||
name: 'Get Current Date',
|
||||
value: 'getCurrentDate',
|
||||
},
|
||||
{
|
||||
name: 'Get Time Between Dates',
|
||||
value: 'getTimeBetweenDates',
|
||||
},
|
||||
{
|
||||
name: 'Round a Date',
|
||||
value: 'roundDate',
|
||||
},
|
||||
{
|
||||
name: 'Subtract From a Date',
|
||||
value: 'subtractFromDate',
|
||||
},
|
||||
],
|
||||
default: 'getCurrentDate',
|
||||
},
|
||||
...CurrentDateDescription,
|
||||
...AddToDateDescription,
|
||||
...SubtractFromDateDescription,
|
||||
...FormatDateDescription,
|
||||
...RoundDateDescription,
|
||||
...GetTimeBetweenDatesDescription,
|
||||
...ExtractDateDescription,
|
||||
],
|
||||
};
|
||||
}
|
||||
|
||||
async execute(this: IExecuteFunctions): Promise<INodeExecutionData[][]> {
|
||||
const items = this.getInputData();
|
||||
const returnData: INodeExecutionData[] = [];
|
||||
const operation = this.getNodeParameter('operation', 0);
|
||||
const workflowTimezone = this.getTimezone();
|
||||
const includeInputFields = this.getNodeParameter(
|
||||
'options.includeInputFields',
|
||||
0,
|
||||
false,
|
||||
) as boolean;
|
||||
|
||||
const copyShallow = (item: INodeExecutionData) => ({
|
||||
json: { ...item.json },
|
||||
binary: item.binary,
|
||||
});
|
||||
|
||||
for (let i = 0; i < items.length; i++) {
|
||||
try {
|
||||
const item: INodeExecutionData = includeInputFields ? copyShallow(items[i]) : { json: {} };
|
||||
item.pairedItem = {
|
||||
item: i,
|
||||
};
|
||||
|
||||
if (operation === 'getCurrentDate') {
|
||||
const includeTime = this.getNodeParameter('includeTime', i) as boolean;
|
||||
const outputFieldName = this.getNodeParameter('outputFieldName', i) as string;
|
||||
const { timezone } = this.getNodeParameter('options', i) as {
|
||||
timezone: string;
|
||||
};
|
||||
|
||||
const newLocal = timezone ? timezone : workflowTimezone;
|
||||
if (DateTime.now().setZone(newLocal).invalidReason === 'unsupported zone') {
|
||||
throw new NodeOperationError(
|
||||
this.getNode(),
|
||||
`The timezone ${newLocal} is not valid. Please check the timezone.`,
|
||||
);
|
||||
}
|
||||
|
||||
if (includeTime) {
|
||||
item.json[outputFieldName] = DateTime.now().setZone(newLocal).toString();
|
||||
} else {
|
||||
item.json[outputFieldName] = DateTime.now().setZone(newLocal).startOf('day').toString();
|
||||
}
|
||||
returnData.push(item);
|
||||
} else if (operation === 'addToDate') {
|
||||
const addToDate = this.getNodeParameter('magnitude', i) as string;
|
||||
const timeUnit = this.getNodeParameter('timeUnit', i) as string;
|
||||
const duration = this.getNodeParameter('duration', i) as number;
|
||||
const outputFieldName = this.getNodeParameter('outputFieldName', i) as string;
|
||||
|
||||
const dateToAdd = parseDate.call(this, addToDate, { timezone: workflowTimezone });
|
||||
const returnedDate = dateToAdd.plus({ [timeUnit]: duration });
|
||||
|
||||
item.json[outputFieldName] = returnedDate.toString();
|
||||
returnData.push(item);
|
||||
} else if (operation === 'subtractFromDate') {
|
||||
const subtractFromDate = this.getNodeParameter('magnitude', i) as string;
|
||||
const timeUnit = this.getNodeParameter('timeUnit', i) as string;
|
||||
const duration = this.getNodeParameter('duration', i) as number;
|
||||
const outputFieldName = this.getNodeParameter('outputFieldName', i) as string;
|
||||
|
||||
const dateToAdd = parseDate.call(this, subtractFromDate, { timezone: workflowTimezone });
|
||||
const returnedDate = dateToAdd.minus({ [timeUnit]: duration });
|
||||
|
||||
item.json[outputFieldName] = returnedDate.toString();
|
||||
returnData.push(item);
|
||||
} else if (operation === 'formatDate') {
|
||||
const date = this.getNodeParameter('date', i) as string;
|
||||
const format = this.getNodeParameter('format', i) as string;
|
||||
const outputFieldName = this.getNodeParameter('outputFieldName', i) as string;
|
||||
const { timezone, fromFormat } = this.getNodeParameter('options', i) as {
|
||||
timezone: boolean;
|
||||
fromFormat: string;
|
||||
};
|
||||
|
||||
if (date === null || date === undefined) {
|
||||
item.json[outputFieldName] = date;
|
||||
} else {
|
||||
const dateLuxon = parseDate.call(this, date, {
|
||||
timezone: timezone ? workflowTimezone : undefined,
|
||||
fromFormat,
|
||||
});
|
||||
if (format === 'custom') {
|
||||
const customFormat = this.getNodeParameter('customFormat', i) as string;
|
||||
item.json[outputFieldName] = dateLuxon.toFormat(customFormat);
|
||||
} else {
|
||||
item.json[outputFieldName] = dateLuxon.toFormat(format);
|
||||
}
|
||||
}
|
||||
returnData.push(item);
|
||||
} else if (operation === 'roundDate') {
|
||||
const date = this.getNodeParameter('date', i) as string;
|
||||
const mode = this.getNodeParameter('mode', i) as string;
|
||||
const outputFieldName = this.getNodeParameter('outputFieldName', i) as string;
|
||||
|
||||
const dateLuxon = parseDate.call(this, date, { timezone: workflowTimezone });
|
||||
|
||||
if (mode === 'roundDown') {
|
||||
const toNearest = this.getNodeParameter('toNearest', i) as string;
|
||||
item.json[outputFieldName] = dateLuxon.startOf(toNearest as DateTimeUnit).toString();
|
||||
} else if (mode === 'roundUp') {
|
||||
const to = this.getNodeParameter('to', i) as string;
|
||||
item.json[outputFieldName] = dateLuxon
|
||||
.plus({ [to]: 1 })
|
||||
.startOf(to as DateTimeUnit)
|
||||
.toString();
|
||||
}
|
||||
returnData.push(item);
|
||||
} else if (operation === 'getTimeBetweenDates') {
|
||||
const startDate = this.getNodeParameter('startDate', i) as string;
|
||||
const endDate = this.getNodeParameter('endDate', i) as string;
|
||||
const unit = this.getNodeParameter('units', i) as DurationUnit[];
|
||||
const outputFieldName = this.getNodeParameter('outputFieldName', i) as string;
|
||||
const { isoString } = this.getNodeParameter('options', i) as {
|
||||
isoString: boolean;
|
||||
};
|
||||
|
||||
const luxonStartDate = parseDate.call(this, startDate, { timezone: workflowTimezone });
|
||||
const luxonEndDate = parseDate.call(this, endDate, { timezone: workflowTimezone });
|
||||
const duration = luxonEndDate.diff(luxonStartDate, unit);
|
||||
if (isoString) {
|
||||
item.json[outputFieldName] = duration.toString();
|
||||
} else {
|
||||
item.json[outputFieldName] = duration.toObject();
|
||||
}
|
||||
returnData.push(item);
|
||||
} else if (operation === 'extractDate') {
|
||||
const date = this.getNodeParameter('date', i) as string | DateTime;
|
||||
const outputFieldName = this.getNodeParameter('outputFieldName', i) as string;
|
||||
const part = this.getNodeParameter('part', i) as keyof DateTime | 'week';
|
||||
|
||||
const parsedDate = parseDate.call(this, date, { timezone: workflowTimezone });
|
||||
const selectedPart = part === 'week' ? parsedDate.weekNumber : parsedDate.get(part);
|
||||
item.json[outputFieldName] = selectedPart;
|
||||
returnData.push(item);
|
||||
}
|
||||
} catch (error) {
|
||||
if (this.continueOnFail()) {
|
||||
returnData.push({ json: { error: error.message } });
|
||||
continue;
|
||||
}
|
||||
throw new NodeOperationError(this.getNode(), error, { itemIndex: i });
|
||||
}
|
||||
}
|
||||
return [returnData];
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,97 @@
|
||||
import type { INodeProperties } from 'n8n-workflow';
|
||||
|
||||
import { includeInputFields } from './common.descriptions';
|
||||
|
||||
export const ExtractDateDescription: INodeProperties[] = [
|
||||
{
|
||||
displayName:
|
||||
'You can also do this using an expression, e.g. <code>{{ your_date.extract("month") }}}</code>. <a target="_blank" href="https://docs.n8n.io/code/cookbook/luxon/">More info</a>',
|
||||
name: 'notice',
|
||||
type: 'notice',
|
||||
default: '',
|
||||
displayOptions: {
|
||||
show: {
|
||||
operation: ['extractDate'],
|
||||
},
|
||||
},
|
||||
},
|
||||
{
|
||||
displayName: 'Date',
|
||||
name: 'date',
|
||||
type: 'string',
|
||||
description: 'The date that you want to round',
|
||||
default: '',
|
||||
displayOptions: {
|
||||
show: {
|
||||
operation: ['extractDate'],
|
||||
},
|
||||
},
|
||||
},
|
||||
{
|
||||
displayName: 'Part',
|
||||
name: 'part',
|
||||
type: 'options',
|
||||
// eslint-disable-next-line n8n-nodes-base/node-param-options-type-unsorted-items
|
||||
options: [
|
||||
{
|
||||
name: 'Year',
|
||||
value: 'year',
|
||||
},
|
||||
{
|
||||
name: 'Month',
|
||||
value: 'month',
|
||||
},
|
||||
{
|
||||
name: 'Week',
|
||||
value: 'week',
|
||||
},
|
||||
{
|
||||
name: 'Day',
|
||||
value: 'day',
|
||||
},
|
||||
{
|
||||
name: 'Hour',
|
||||
value: 'hour',
|
||||
},
|
||||
{
|
||||
name: 'Minute',
|
||||
value: 'minute',
|
||||
},
|
||||
{
|
||||
name: 'Second',
|
||||
value: 'second',
|
||||
},
|
||||
],
|
||||
default: 'month',
|
||||
displayOptions: {
|
||||
show: {
|
||||
operation: ['extractDate'],
|
||||
},
|
||||
},
|
||||
},
|
||||
{
|
||||
displayName: 'Output Field Name',
|
||||
name: 'outputFieldName',
|
||||
type: 'string',
|
||||
default: 'datePart',
|
||||
description: 'Name of the field to put the output in',
|
||||
displayOptions: {
|
||||
show: {
|
||||
operation: ['extractDate'],
|
||||
},
|
||||
},
|
||||
},
|
||||
{
|
||||
displayName: 'Options',
|
||||
name: 'options',
|
||||
type: 'collection',
|
||||
placeholder: 'Add option',
|
||||
displayOptions: {
|
||||
show: {
|
||||
operation: ['extractDate'],
|
||||
},
|
||||
},
|
||||
default: {},
|
||||
options: [includeInputFields],
|
||||
},
|
||||
];
|
||||
@@ -0,0 +1,142 @@
|
||||
import type { INodeProperties } from 'n8n-workflow';
|
||||
|
||||
import { includeInputFields } from './common.descriptions';
|
||||
|
||||
export const FormatDateDescription: INodeProperties[] = [
|
||||
{
|
||||
displayName:
|
||||
"You can also do this using an expression, e.g. <code>{{your_date.format('yyyy-MM-dd')}}</code>. <a target='_blank' href='https://docs.n8n.io/code/cookbook/luxon/'>More info</a>",
|
||||
name: 'notice',
|
||||
type: 'notice',
|
||||
default: '',
|
||||
displayOptions: {
|
||||
show: {
|
||||
operation: ['formatDate'],
|
||||
},
|
||||
},
|
||||
},
|
||||
{
|
||||
displayName: 'Date',
|
||||
name: 'date',
|
||||
type: 'string',
|
||||
description: 'The date that you want to format',
|
||||
default: '',
|
||||
displayOptions: {
|
||||
show: {
|
||||
operation: ['formatDate'],
|
||||
},
|
||||
},
|
||||
},
|
||||
{
|
||||
displayName: 'Format',
|
||||
name: 'format',
|
||||
type: 'options',
|
||||
displayOptions: {
|
||||
show: {
|
||||
operation: ['formatDate'],
|
||||
},
|
||||
},
|
||||
// eslint-disable-next-line n8n-nodes-base/node-param-options-type-unsorted-items
|
||||
options: [
|
||||
{
|
||||
name: 'Custom Format',
|
||||
value: 'custom',
|
||||
},
|
||||
{
|
||||
name: 'MM/DD/YYYY',
|
||||
value: 'MM/dd/yyyy',
|
||||
description: 'Example: 09/04/1986',
|
||||
},
|
||||
{
|
||||
name: 'YYYY/MM/DD',
|
||||
value: 'yyyy/MM/dd',
|
||||
description: 'Example: 1986/04/09',
|
||||
},
|
||||
{
|
||||
name: 'MMMM DD YYYY',
|
||||
value: 'MMMM dd yyyy',
|
||||
description: 'Example: April 09 1986',
|
||||
},
|
||||
{
|
||||
name: 'MM-DD-YYYY',
|
||||
value: 'MM-dd-yyyy',
|
||||
description: 'Example: 09-04-1986',
|
||||
},
|
||||
{
|
||||
name: 'YYYY-MM-DD',
|
||||
value: 'yyyy-MM-dd',
|
||||
description: 'Example: 1986-04-09',
|
||||
},
|
||||
{
|
||||
name: 'Unix Timestamp',
|
||||
value: 'X',
|
||||
description: 'Example: 1672531200',
|
||||
},
|
||||
{
|
||||
name: 'Unix Ms Timestamp',
|
||||
value: 'x',
|
||||
description: 'Example: 1674691200000',
|
||||
},
|
||||
],
|
||||
default: 'MM/dd/yyyy',
|
||||
description: 'The format to convert the date to',
|
||||
},
|
||||
{
|
||||
displayName: 'Custom Format',
|
||||
name: 'customFormat',
|
||||
type: 'string',
|
||||
displayOptions: {
|
||||
show: {
|
||||
format: ['custom'],
|
||||
operation: ['formatDate'],
|
||||
},
|
||||
},
|
||||
hint: 'List of special tokens <a target="_blank" href="https://moment.github.io/luxon/#/formatting?id=table-of-tokens">More info</a>',
|
||||
default: '',
|
||||
placeholder: 'yyyy-MM-dd',
|
||||
},
|
||||
{
|
||||
displayName: 'Output Field Name',
|
||||
name: 'outputFieldName',
|
||||
type: 'string',
|
||||
default: 'formattedDate',
|
||||
description: 'Name of the field to put the output in',
|
||||
displayOptions: {
|
||||
show: {
|
||||
operation: ['formatDate'],
|
||||
},
|
||||
},
|
||||
},
|
||||
{
|
||||
displayName: 'Options',
|
||||
name: 'options',
|
||||
type: 'collection',
|
||||
placeholder: 'Add option',
|
||||
displayOptions: {
|
||||
show: {
|
||||
operation: ['formatDate'],
|
||||
},
|
||||
},
|
||||
default: {},
|
||||
options: [
|
||||
includeInputFields,
|
||||
{
|
||||
displayName: 'From Date Format',
|
||||
name: 'fromFormat',
|
||||
type: 'string',
|
||||
default: 'e.g yyyyMMdd',
|
||||
hint: 'Tokens are case sensitive',
|
||||
// eslint-disable-next-line n8n-nodes-base/node-param-description-miscased-id
|
||||
description:
|
||||
'Format in which the input \'Date\' is, it\'s helpful when the format is not recognized automatically. Use those <a href="https://moment.github.io/luxon/#/formatting?id=table-of-tokens&id=table-of-tokens" target="_blank">tokens</a> to define the format.',
|
||||
},
|
||||
{
|
||||
displayName: 'Use Workflow Timezone',
|
||||
name: 'timezone',
|
||||
type: 'boolean',
|
||||
default: false,
|
||||
description: "Whether to use the timezone of the input or the workflow's timezone",
|
||||
},
|
||||
],
|
||||
},
|
||||
];
|
||||
@@ -0,0 +1,58 @@
|
||||
import { DateTime } from 'luxon';
|
||||
import moment from 'moment-timezone';
|
||||
import type { IExecuteFunctions } from 'n8n-workflow';
|
||||
import { NodeOperationError } from 'n8n-workflow';
|
||||
|
||||
export function parseDate(
|
||||
this: IExecuteFunctions,
|
||||
date: string | number | DateTime,
|
||||
options: Partial<{
|
||||
timezone: string;
|
||||
fromFormat: string;
|
||||
}> = {},
|
||||
) {
|
||||
let parsedDate;
|
||||
|
||||
if (date instanceof DateTime) {
|
||||
parsedDate = date;
|
||||
} else {
|
||||
// Check if the input is a number, don't convert to number if fromFormat is set
|
||||
if (!Number.isNaN(Number(date)) && !options.fromFormat) {
|
||||
//input is a number, convert to number in case it is a string formatted number
|
||||
date = Number(date);
|
||||
// check if the number is a timestamp in float format and convert to integer
|
||||
if (!Number.isInteger(date)) {
|
||||
date = date * 1000;
|
||||
}
|
||||
}
|
||||
|
||||
let timezone = options.timezone;
|
||||
if (Number.isInteger(date)) {
|
||||
const timestampLengthInMilliseconds1990 = 12;
|
||||
// check if the number is a timestamp in seconds or milliseconds and create a moment object accordingly
|
||||
if (date.toString().length < timestampLengthInMilliseconds1990) {
|
||||
parsedDate = DateTime.fromSeconds(date as number);
|
||||
} else {
|
||||
parsedDate = DateTime.fromMillis(date as number);
|
||||
}
|
||||
} else {
|
||||
if (!timezone && (date as string).includes('+')) {
|
||||
const offset = (date as string).split('+')[1].slice(0, 2) as unknown as number;
|
||||
timezone = `Etc/GMT-${offset * 1}`;
|
||||
}
|
||||
|
||||
if (options.fromFormat) {
|
||||
parsedDate = DateTime.fromFormat(date as string, options.fromFormat);
|
||||
} else {
|
||||
parsedDate = DateTime.fromISO(moment(date).toISOString());
|
||||
}
|
||||
}
|
||||
|
||||
parsedDate = parsedDate.setZone(timezone || 'Etc/UTC');
|
||||
|
||||
if (parsedDate.invalidReason === 'unparsable') {
|
||||
throw new NodeOperationError(this.getNode(), 'Invalid date format');
|
||||
}
|
||||
}
|
||||
return parsedDate;
|
||||
}
|
||||
@@ -0,0 +1,108 @@
|
||||
import type { INodeProperties } from 'n8n-workflow';
|
||||
|
||||
import { includeInputFields } from './common.descriptions';
|
||||
|
||||
export const GetTimeBetweenDatesDescription: INodeProperties[] = [
|
||||
{
|
||||
displayName: 'Start Date',
|
||||
name: 'startDate',
|
||||
type: 'string',
|
||||
default: '',
|
||||
displayOptions: {
|
||||
show: {
|
||||
operation: ['getTimeBetweenDates'],
|
||||
},
|
||||
},
|
||||
},
|
||||
{
|
||||
displayName: 'End Date',
|
||||
name: 'endDate',
|
||||
type: 'string',
|
||||
default: '',
|
||||
displayOptions: {
|
||||
show: {
|
||||
operation: ['getTimeBetweenDates'],
|
||||
},
|
||||
},
|
||||
},
|
||||
{
|
||||
displayName: 'Units',
|
||||
name: 'units',
|
||||
type: 'multiOptions',
|
||||
// eslint-disable-next-line n8n-nodes-base/node-param-multi-options-type-unsorted-items
|
||||
options: [
|
||||
{
|
||||
name: 'Year',
|
||||
value: 'year',
|
||||
},
|
||||
{
|
||||
name: 'Month',
|
||||
value: 'month',
|
||||
},
|
||||
{
|
||||
name: 'Week',
|
||||
value: 'week',
|
||||
},
|
||||
{
|
||||
name: 'Day',
|
||||
value: 'day',
|
||||
},
|
||||
{
|
||||
name: 'Hour',
|
||||
value: 'hour',
|
||||
},
|
||||
{
|
||||
name: 'Minute',
|
||||
value: 'minute',
|
||||
},
|
||||
{
|
||||
name: 'Second',
|
||||
value: 'second',
|
||||
},
|
||||
{
|
||||
name: 'Millisecond',
|
||||
value: 'millisecond',
|
||||
},
|
||||
],
|
||||
displayOptions: {
|
||||
show: {
|
||||
operation: ['getTimeBetweenDates'],
|
||||
},
|
||||
},
|
||||
default: ['day'],
|
||||
},
|
||||
{
|
||||
displayName: 'Output Field Name',
|
||||
name: 'outputFieldName',
|
||||
type: 'string',
|
||||
default: 'timeDifference',
|
||||
description: 'Name of the field to put the output in',
|
||||
displayOptions: {
|
||||
show: {
|
||||
operation: ['getTimeBetweenDates'],
|
||||
},
|
||||
},
|
||||
},
|
||||
{
|
||||
displayName: 'Options',
|
||||
name: 'options',
|
||||
type: 'collection',
|
||||
placeholder: 'Add option',
|
||||
displayOptions: {
|
||||
show: {
|
||||
operation: ['getTimeBetweenDates'],
|
||||
},
|
||||
},
|
||||
default: {},
|
||||
options: [
|
||||
includeInputFields,
|
||||
{
|
||||
displayName: 'Output as ISO String',
|
||||
name: 'isoString',
|
||||
type: 'boolean',
|
||||
default: false,
|
||||
description: 'Whether to output the date as ISO string or not',
|
||||
},
|
||||
],
|
||||
},
|
||||
];
|
||||
@@ -0,0 +1,137 @@
|
||||
import type { INodeProperties } from 'n8n-workflow';
|
||||
|
||||
import { includeInputFields } from './common.descriptions';
|
||||
|
||||
export const RoundDateDescription: INodeProperties[] = [
|
||||
{
|
||||
displayName:
|
||||
"You can also do this using an expression, e.g. <code>{{ your_date.beginningOf('month') }}</code> or <code>{{ your_date.endOfMonth() }}</code>. <a target='_blank' href='https://docs.n8n.io/code/cookbook/luxon/'>More info</a>",
|
||||
name: 'notice',
|
||||
type: 'notice',
|
||||
default: '',
|
||||
displayOptions: {
|
||||
show: {
|
||||
operation: ['roundDate'],
|
||||
},
|
||||
},
|
||||
},
|
||||
{
|
||||
displayName: 'Date',
|
||||
name: 'date',
|
||||
type: 'string',
|
||||
description: 'The date that you want to round',
|
||||
default: '',
|
||||
displayOptions: {
|
||||
show: {
|
||||
operation: ['roundDate'],
|
||||
},
|
||||
},
|
||||
},
|
||||
{
|
||||
displayName: 'Mode',
|
||||
name: 'mode',
|
||||
type: 'options',
|
||||
options: [
|
||||
{
|
||||
name: 'Round Down',
|
||||
value: 'roundDown',
|
||||
},
|
||||
{
|
||||
name: 'Round Up',
|
||||
value: 'roundUp',
|
||||
},
|
||||
],
|
||||
default: 'roundDown',
|
||||
displayOptions: {
|
||||
show: {
|
||||
operation: ['roundDate'],
|
||||
},
|
||||
},
|
||||
},
|
||||
{
|
||||
displayName: 'To Nearest',
|
||||
name: 'toNearest',
|
||||
type: 'options',
|
||||
// eslint-disable-next-line n8n-nodes-base/node-param-options-type-unsorted-items
|
||||
options: [
|
||||
{
|
||||
name: 'Year',
|
||||
value: 'year',
|
||||
},
|
||||
{
|
||||
name: 'Month',
|
||||
value: 'month',
|
||||
},
|
||||
{
|
||||
name: 'Week',
|
||||
value: 'week',
|
||||
},
|
||||
{
|
||||
name: 'Day',
|
||||
value: 'day',
|
||||
},
|
||||
{
|
||||
name: 'Hour',
|
||||
value: 'hour',
|
||||
},
|
||||
{
|
||||
name: 'Minute',
|
||||
value: 'minute',
|
||||
},
|
||||
{
|
||||
name: 'Second',
|
||||
value: 'second',
|
||||
},
|
||||
],
|
||||
default: 'month',
|
||||
displayOptions: {
|
||||
show: {
|
||||
operation: ['roundDate'],
|
||||
mode: ['roundDown'],
|
||||
},
|
||||
},
|
||||
},
|
||||
{
|
||||
displayName: 'To',
|
||||
name: 'to',
|
||||
type: 'options',
|
||||
options: [
|
||||
{
|
||||
name: 'End of Month',
|
||||
value: 'month',
|
||||
},
|
||||
],
|
||||
default: 'month',
|
||||
displayOptions: {
|
||||
show: {
|
||||
operation: ['roundDate'],
|
||||
mode: ['roundUp'],
|
||||
},
|
||||
},
|
||||
},
|
||||
{
|
||||
displayName: 'Output Field Name',
|
||||
name: 'outputFieldName',
|
||||
type: 'string',
|
||||
default: 'roundedDate',
|
||||
description: 'Name of the field to put the output in',
|
||||
displayOptions: {
|
||||
show: {
|
||||
operation: ['roundDate'],
|
||||
},
|
||||
},
|
||||
},
|
||||
{
|
||||
displayName: 'Options',
|
||||
name: 'options',
|
||||
type: 'collection',
|
||||
placeholder: 'Add option',
|
||||
displayOptions: {
|
||||
show: {
|
||||
operation: ['roundDate'],
|
||||
},
|
||||
},
|
||||
default: {},
|
||||
options: [includeInputFields],
|
||||
},
|
||||
];
|
||||
@@ -0,0 +1,120 @@
|
||||
import type { INodeProperties } from 'n8n-workflow';
|
||||
|
||||
import { includeInputFields } from './common.descriptions';
|
||||
|
||||
export const SubtractFromDateDescription: INodeProperties[] = [
|
||||
{
|
||||
displayName:
|
||||
"You can also do this using an expression, e.g. <code>{{your_date.minus(5, 'minutes')}}</code>. <a target='_blank' href='https://docs.n8n.io/code/cookbook/luxon/'>More info</a>",
|
||||
name: 'notice',
|
||||
type: 'notice',
|
||||
default: '',
|
||||
displayOptions: {
|
||||
show: {
|
||||
operation: ['subtractFromDate'],
|
||||
},
|
||||
},
|
||||
},
|
||||
{
|
||||
displayName: 'Date to Subtract From',
|
||||
name: 'magnitude',
|
||||
type: 'string',
|
||||
description: 'The date that you want to change',
|
||||
default: '',
|
||||
displayOptions: {
|
||||
show: {
|
||||
operation: ['subtractFromDate'],
|
||||
},
|
||||
},
|
||||
required: true,
|
||||
},
|
||||
{
|
||||
displayName: 'Time Unit to Subtract',
|
||||
name: 'timeUnit',
|
||||
description: 'Time unit for Duration parameter below',
|
||||
displayOptions: {
|
||||
show: {
|
||||
operation: ['subtractFromDate'],
|
||||
},
|
||||
},
|
||||
type: 'options',
|
||||
// eslint-disable-next-line n8n-nodes-base/node-param-options-type-unsorted-items
|
||||
options: [
|
||||
{
|
||||
name: 'Years',
|
||||
value: 'years',
|
||||
},
|
||||
{
|
||||
name: 'Quarters',
|
||||
value: 'quarters',
|
||||
},
|
||||
{
|
||||
name: 'Months',
|
||||
value: 'months',
|
||||
},
|
||||
{
|
||||
name: 'Weeks',
|
||||
value: 'weeks',
|
||||
},
|
||||
{
|
||||
name: 'Days',
|
||||
value: 'days',
|
||||
},
|
||||
{
|
||||
name: 'Hours',
|
||||
value: 'hours',
|
||||
},
|
||||
{
|
||||
name: 'Minutes',
|
||||
value: 'minutes',
|
||||
},
|
||||
{
|
||||
name: 'Seconds',
|
||||
value: 'seconds',
|
||||
},
|
||||
{
|
||||
name: 'Milliseconds',
|
||||
value: 'milliseconds',
|
||||
},
|
||||
],
|
||||
default: 'days',
|
||||
required: true,
|
||||
},
|
||||
{
|
||||
displayName: 'Duration',
|
||||
name: 'duration',
|
||||
type: 'number',
|
||||
description: 'The number of time units to subtract from the date',
|
||||
default: 0,
|
||||
displayOptions: {
|
||||
show: {
|
||||
operation: ['subtractFromDate'],
|
||||
},
|
||||
},
|
||||
},
|
||||
{
|
||||
displayName: 'Output Field Name',
|
||||
name: 'outputFieldName',
|
||||
type: 'string',
|
||||
default: 'newDate',
|
||||
description: 'Name of the field to put the output in',
|
||||
displayOptions: {
|
||||
show: {
|
||||
operation: ['subtractFromDate'],
|
||||
},
|
||||
},
|
||||
},
|
||||
{
|
||||
displayName: 'Options',
|
||||
name: 'options',
|
||||
type: 'collection',
|
||||
placeholder: 'Add option',
|
||||
displayOptions: {
|
||||
show: {
|
||||
operation: ['subtractFromDate'],
|
||||
},
|
||||
},
|
||||
default: {},
|
||||
options: [includeInputFields],
|
||||
},
|
||||
];
|
||||
@@ -0,0 +1,9 @@
|
||||
import type { INodeProperties } from 'n8n-workflow';
|
||||
|
||||
export const includeInputFields: INodeProperties = {
|
||||
displayName: 'Include Input Fields',
|
||||
name: 'includeInputFields',
|
||||
type: 'boolean',
|
||||
default: false,
|
||||
description: 'Whether to include all fields of the input item in the output item',
|
||||
};
|
||||
@@ -0,0 +1,13 @@
|
||||
import { NodeTestHarness } from '@nodes-testing/node-test-harness';
|
||||
import moment from 'moment-timezone';
|
||||
|
||||
describe('Test DateTime Node', () => {
|
||||
// ! When making changes to the Workflow test files make sure to export env TZ=UTC as Github Actions runs in UTC timezone
|
||||
if (new Date().getTimezoneOffset() === 0 || moment().utcOffset() === 0) {
|
||||
new NodeTestHarness().setupTests();
|
||||
} else {
|
||||
it('Skipped because timezone is not UTC', () => {
|
||||
expect(true).toBe(true);
|
||||
});
|
||||
}
|
||||
});
|
||||
@@ -0,0 +1,262 @@
|
||||
{
|
||||
"name": "node-360-quick-overhaul-of-date-and-time-node",
|
||||
"nodes": [
|
||||
{
|
||||
"parameters": {},
|
||||
"id": "21ff2e15-375d-4e68-b1ca-d48a110be238",
|
||||
"name": "When clicking \"Execute Workflow\"",
|
||||
"type": "n8n-nodes-base.manualTrigger",
|
||||
"typeVersion": 1,
|
||||
"position": [-420, 20]
|
||||
},
|
||||
{
|
||||
"parameters": {
|
||||
"operation": "addToDate",
|
||||
"magnitude": "={{ $json.currentDate }}",
|
||||
"duration": 2
|
||||
},
|
||||
"id": "b99986f1-edeb-434c-b7ed-9cc86eaec522",
|
||||
"name": "Add to date",
|
||||
"type": "n8n-nodes-base.dateTime",
|
||||
"typeVersion": 2,
|
||||
"position": [140, 40]
|
||||
},
|
||||
{
|
||||
"parameters": {
|
||||
"operation": "subtractFromDate",
|
||||
"magnitude": "={{ $json.newDate }}",
|
||||
"duration": 2
|
||||
},
|
||||
"id": "aa75a04b-0d42-46ff-87e7-75d4b4f6c7ea",
|
||||
"name": "Subtract date",
|
||||
"type": "n8n-nodes-base.dateTime",
|
||||
"typeVersion": 2,
|
||||
"position": [300, 200]
|
||||
},
|
||||
{
|
||||
"parameters": {
|
||||
"operation": "formatDate",
|
||||
"date": "={{ $json.newDate }}",
|
||||
"format": "yyyy/MM/dd"
|
||||
},
|
||||
"id": "52076d89-bc6d-4253-8ca4-9aad3a058d17",
|
||||
"name": "Format Date",
|
||||
"type": "n8n-nodes-base.dateTime",
|
||||
"typeVersion": 2,
|
||||
"position": [420, 40]
|
||||
},
|
||||
{
|
||||
"parameters": {
|
||||
"operation": "roundDate",
|
||||
"date": "={{ $json.formattedDate }}",
|
||||
"toNearest": "day"
|
||||
},
|
||||
"id": "10016499-c9da-4984-9a5f-2f8c8844fb63",
|
||||
"name": "Round Date",
|
||||
"type": "n8n-nodes-base.dateTime",
|
||||
"typeVersion": 2,
|
||||
"position": [560, 200]
|
||||
},
|
||||
{
|
||||
"parameters": {
|
||||
"operation": "getTimeBetweenDates",
|
||||
"startDate": "={{ $node['Subtract date'].json.newDate }}",
|
||||
"endDate": "={{ $node['Add to date'].json.newDate }}",
|
||||
"units": ["day"]
|
||||
},
|
||||
"id": "f62b6d0b-b13a-4fcd-b4eb-3ec7ea85e80c",
|
||||
"name": "Get between date",
|
||||
"type": "n8n-nodes-base.dateTime",
|
||||
"typeVersion": 2,
|
||||
"position": [660, 40]
|
||||
},
|
||||
{
|
||||
"parameters": {
|
||||
"operation": "extractDate",
|
||||
"date": "={{ $node.Code.json.currentDate }}",
|
||||
"part": "hour",
|
||||
"outputFieldName": "date"
|
||||
},
|
||||
"id": "764e3e08-f71b-4e42-b059-36285076fe10",
|
||||
"name": "Extract Date",
|
||||
"type": "n8n-nodes-base.dateTime",
|
||||
"typeVersion": 2,
|
||||
"position": [780, 220]
|
||||
},
|
||||
{
|
||||
"parameters": {
|
||||
"options": {
|
||||
"fromFormat": ""
|
||||
}
|
||||
},
|
||||
"id": "f0b75198-74a4-4a13-8842-340539f41d80",
|
||||
"name": "V1",
|
||||
"type": "n8n-nodes-base.dateTime",
|
||||
"typeVersion": 1,
|
||||
"position": [0, -180],
|
||||
"disabled": true
|
||||
},
|
||||
{
|
||||
"parameters": {
|
||||
"data": {
|
||||
"currentDate": "2023-04-11T13:51:59.965+00:00"
|
||||
}
|
||||
},
|
||||
"id": "7ba0c2a1-a683-4975-a2ca-70904111a3fc",
|
||||
"name": "Code",
|
||||
"type": "n8n-nodes-testing.testData",
|
||||
"typeVersion": 1,
|
||||
"position": [-140, 140]
|
||||
}
|
||||
],
|
||||
"pinData": {
|
||||
"Code": [
|
||||
{
|
||||
"json": {
|
||||
"currentDate": "2023-04-11T13:51:59.965+00:00"
|
||||
}
|
||||
}
|
||||
],
|
||||
"Add to date": [
|
||||
{
|
||||
"json": {
|
||||
"newDate": "2023-04-13T13:51:59.965+00:00"
|
||||
}
|
||||
}
|
||||
],
|
||||
"Subtract date": [
|
||||
{
|
||||
"json": {
|
||||
"newDate": "2023-04-11T13:51:59.965+00:00"
|
||||
}
|
||||
}
|
||||
],
|
||||
"Format Date": [
|
||||
{
|
||||
"json": {
|
||||
"formattedDate": "2023/04/11"
|
||||
}
|
||||
}
|
||||
],
|
||||
"Round Date": [
|
||||
{
|
||||
"json": {
|
||||
"roundedDate": "2023-04-11T00:00:00.000+00:00"
|
||||
}
|
||||
}
|
||||
],
|
||||
"Get between date": [
|
||||
{
|
||||
"json": {
|
||||
"timeDifference": {
|
||||
"days": 2
|
||||
}
|
||||
}
|
||||
}
|
||||
],
|
||||
"Extract Date": [
|
||||
{
|
||||
"json": {
|
||||
"date": 13
|
||||
}
|
||||
}
|
||||
]
|
||||
},
|
||||
"connections": {
|
||||
"When clicking \"Execute Workflow\"": {
|
||||
"main": [
|
||||
[
|
||||
{
|
||||
"node": "V1",
|
||||
"type": "main",
|
||||
"index": 0
|
||||
},
|
||||
{
|
||||
"node": "Code",
|
||||
"type": "main",
|
||||
"index": 0
|
||||
}
|
||||
]
|
||||
]
|
||||
},
|
||||
"Add to date": {
|
||||
"main": [
|
||||
[
|
||||
{
|
||||
"node": "Subtract date",
|
||||
"type": "main",
|
||||
"index": 0
|
||||
}
|
||||
]
|
||||
]
|
||||
},
|
||||
"Subtract date": {
|
||||
"main": [
|
||||
[
|
||||
{
|
||||
"node": "Format Date",
|
||||
"type": "main",
|
||||
"index": 0
|
||||
}
|
||||
]
|
||||
]
|
||||
},
|
||||
"Format Date": {
|
||||
"main": [
|
||||
[
|
||||
{
|
||||
"node": "Round Date",
|
||||
"type": "main",
|
||||
"index": 0
|
||||
}
|
||||
]
|
||||
]
|
||||
},
|
||||
"Round Date": {
|
||||
"main": [
|
||||
[
|
||||
{
|
||||
"node": "Get between date",
|
||||
"type": "main",
|
||||
"index": 0
|
||||
}
|
||||
]
|
||||
]
|
||||
},
|
||||
"Get between date": {
|
||||
"main": [
|
||||
[
|
||||
{
|
||||
"node": "Extract Date",
|
||||
"type": "main",
|
||||
"index": 0
|
||||
}
|
||||
]
|
||||
]
|
||||
},
|
||||
"Code": {
|
||||
"main": [
|
||||
[
|
||||
{
|
||||
"node": "Add to date",
|
||||
"type": "main",
|
||||
"index": 0
|
||||
}
|
||||
]
|
||||
]
|
||||
}
|
||||
},
|
||||
"active": false,
|
||||
"settings": {
|
||||
"saveManualExecutions": false,
|
||||
"callerPolicy": "workflowsFromSameOwner",
|
||||
"timezone": "Etc/GMT",
|
||||
"executionTimeout": -1
|
||||
},
|
||||
"versionId": "c21daa0b-83ae-45f1-b680-d2e57423800b",
|
||||
"id": "48",
|
||||
"meta": {
|
||||
"instanceId": "8e9416f42a954d0a370d988ac3c0f916f44074a6e45189164b1a8559394a7516"
|
||||
},
|
||||
"tags": []
|
||||
}
|
||||
@@ -0,0 +1,542 @@
|
||||
{
|
||||
"name": "My workflow 10",
|
||||
"nodes": [
|
||||
{
|
||||
"parameters": {},
|
||||
"id": "0b90cdc3-807a-4849-b2e2-a017eb77df17",
|
||||
"name": "When clicking \"Execute Workflow\"",
|
||||
"type": "n8n-nodes-base.manualTrigger",
|
||||
"typeVersion": 1,
|
||||
"position": [20, 1820]
|
||||
},
|
||||
{
|
||||
"parameters": {
|
||||
"action": "calculate",
|
||||
"value": "08/01/2022",
|
||||
"duration": 10,
|
||||
"options": {}
|
||||
},
|
||||
"id": "4a7807ca-e44c-46b4-9d2c-3424b1883c61",
|
||||
"name": "Calculate Date: Add Day",
|
||||
"type": "n8n-nodes-base.dateTime",
|
||||
"typeVersion": 1,
|
||||
"position": [500, 1740]
|
||||
},
|
||||
{
|
||||
"parameters": {
|
||||
"action": "calculate",
|
||||
"value": "08/01/2022",
|
||||
"duration": 2,
|
||||
"timeUnit": "quarters",
|
||||
"options": {}
|
||||
},
|
||||
"id": "04d26b36-9a31-4fc8-bbf4-4b6d8b9304bb",
|
||||
"name": "Calculate Date: Substract Quarter",
|
||||
"type": "n8n-nodes-base.dateTime",
|
||||
"typeVersion": 1,
|
||||
"position": [500, 2100]
|
||||
},
|
||||
{
|
||||
"parameters": {
|
||||
"action": "calculate",
|
||||
"value": "08/01/2022",
|
||||
"operation": "subtract",
|
||||
"duration": 2,
|
||||
"options": {}
|
||||
},
|
||||
"id": "617145da-26c5-491b-bc58-a10fbb5a1825",
|
||||
"name": "Calculate Date: Substract Day",
|
||||
"type": "n8n-nodes-base.dateTime",
|
||||
"typeVersion": 1,
|
||||
"position": [500, 1920]
|
||||
},
|
||||
{
|
||||
"parameters": {
|
||||
"action": "calculate",
|
||||
"value": "08/01/2022",
|
||||
"duration": 2,
|
||||
"timeUnit": "months",
|
||||
"options": {}
|
||||
},
|
||||
"id": "c7b4967f-3ae4-452b-8d54-aa1623194f2b",
|
||||
"name": "Calculate Date: Add months",
|
||||
"type": "n8n-nodes-base.dateTime",
|
||||
"typeVersion": 1,
|
||||
"position": [500, 2280]
|
||||
},
|
||||
{
|
||||
"parameters": {
|
||||
"action": "calculate",
|
||||
"value": "08/01/2022",
|
||||
"operation": "subtract",
|
||||
"duration": 2,
|
||||
"timeUnit": "months",
|
||||
"options": {}
|
||||
},
|
||||
"id": "a22a536c-bf23-4ff0-a3ad-b3761dfb3add",
|
||||
"name": "Calculate Date: Substract Months",
|
||||
"type": "n8n-nodes-base.dateTime",
|
||||
"typeVersion": 1,
|
||||
"position": [500, 2440]
|
||||
},
|
||||
{
|
||||
"parameters": {
|
||||
"value": "08/01/2022",
|
||||
"toFormat": "YYYY/MM/DD",
|
||||
"options": {}
|
||||
},
|
||||
"id": "3ecc8ea0-9605-4017-b5e0-a9ddde4c1a4a",
|
||||
"name": "Calculate Date: Format YYYY/MM/DD",
|
||||
"type": "n8n-nodes-base.dateTime",
|
||||
"typeVersion": 1,
|
||||
"position": [500, 2620]
|
||||
},
|
||||
{
|
||||
"parameters": {
|
||||
"value": "08/01/2022",
|
||||
"toFormat": "YYYY/MM/DD",
|
||||
"options": {
|
||||
"fromTimezone": "US/Hawaii"
|
||||
}
|
||||
},
|
||||
"id": "c99c7124-c388-4c97-8e6e-8158ba83bddd",
|
||||
"name": "Calculate Date: Format YYYY/MM/DD with Timezone",
|
||||
"type": "n8n-nodes-base.dateTime",
|
||||
"typeVersion": 1,
|
||||
"position": [500, 2800]
|
||||
},
|
||||
{
|
||||
"parameters": {
|
||||
"value": "08/01/2022",
|
||||
"toFormat": "YYYY/MM/DD",
|
||||
"options": {
|
||||
"fromTimezone": "US/Hawaii",
|
||||
"toTimezone": "US/Pacific"
|
||||
}
|
||||
},
|
||||
"id": "40abfde6-66f2-44a9-a16f-3d981178da84",
|
||||
"name": "Calculate Date: Format YYYY/MM/DD with Timezone1",
|
||||
"type": "n8n-nodes-base.dateTime",
|
||||
"typeVersion": 1,
|
||||
"position": [500, 2980]
|
||||
},
|
||||
{
|
||||
"parameters": {
|
||||
"value": "08/01/2022",
|
||||
"toFormat": "x",
|
||||
"options": {
|
||||
"fromTimezone": "US/Hawaii",
|
||||
"toTimezone": "US/Pacific"
|
||||
}
|
||||
},
|
||||
"id": "20ea9e76-d656-406f-8e3d-a51712c2657d",
|
||||
"name": "Calculate Date: Format YYYY/MM/DD with Timezone Unix",
|
||||
"type": "n8n-nodes-base.dateTime",
|
||||
"typeVersion": 1,
|
||||
"position": [20, 2340]
|
||||
},
|
||||
{
|
||||
"parameters": {
|
||||
"value": "2022-01-12",
|
||||
"toFormat": "MM-DD-YYYY",
|
||||
"options": {
|
||||
"fromFormat": "YYYY-DD-MM",
|
||||
"fromTimezone": "US/Hawaii",
|
||||
"toTimezone": "US/Pacific"
|
||||
}
|
||||
},
|
||||
"id": "53ddcd66-3cb5-47bb-bd59-64a70fc599b7",
|
||||
"name": "Calculate Date: Format YYYY/MM/DD with Timezone with special zone",
|
||||
"type": "n8n-nodes-base.dateTime",
|
||||
"typeVersion": 1,
|
||||
"position": [20, 2520]
|
||||
},
|
||||
{
|
||||
"parameters": {
|
||||
"functionCode": "return [\n {\n \"Id\": \"18162\",\n \"Start_time\": 1663801200000,\n \"End_time\": 1663804800000,\n \"Room\": \" The Stadium\"\n },\n {\n \"Id\": \"18173\",\n \"Start_time\": 1663797600000,\n \"End_time\": 1663801200000,\n \"Room\": \" The Stadium\"\n },\n {\n \"Id\": \"18178\",\n \"Start_time\": 1663804800000,\n \"End_time\": 1663808400000,\n \"Room\": \" The Stadium\"\n },\n {\n \"Id\": \"18182\",\n \"Start_time\": 1663801200000,\n \"End_time\": 1663804800000,\n \"Room\": \" The Garden\"\n }\n]"
|
||||
},
|
||||
"id": "0933e36d-43f4-46b5-8c3f-8d397d93a24c",
|
||||
"name": "Mock Data",
|
||||
"type": "n8n-nodes-base.function",
|
||||
"typeVersion": 1,
|
||||
"position": [-140, 1200]
|
||||
},
|
||||
{
|
||||
"parameters": {
|
||||
"value": "1663801200000",
|
||||
"options": {
|
||||
"fromFormat": "x",
|
||||
"toTimezone": "UTC"
|
||||
}
|
||||
},
|
||||
"id": "35eae914-b744-4a0b-a9ac-eab8bd685f02",
|
||||
"name": "Fixed Value",
|
||||
"type": "n8n-nodes-base.dateTime",
|
||||
"typeVersion": 1,
|
||||
"position": [160, 1080]
|
||||
},
|
||||
{
|
||||
"parameters": {
|
||||
"value": "={{parseInt(1663801200000)}}",
|
||||
"options": {
|
||||
"fromFormat": "x",
|
||||
"toTimezone": "UTC"
|
||||
}
|
||||
},
|
||||
"id": "e7d16772-843d-43da-a411-ee46253619e8",
|
||||
"name": "parseInt on fixed",
|
||||
"type": "n8n-nodes-base.dateTime",
|
||||
"typeVersion": 1,
|
||||
"position": [160, 1580]
|
||||
},
|
||||
{
|
||||
"parameters": {
|
||||
"value": "={{ $json[\"Start_time\"] }}",
|
||||
"options": {
|
||||
"fromFormat": "x",
|
||||
"toTimezone": "UTC"
|
||||
}
|
||||
},
|
||||
"id": "daf8a9da-7cab-4bb6-91fd-9a7315ecc61b",
|
||||
"name": "Without toString()",
|
||||
"type": "n8n-nodes-base.dateTime",
|
||||
"typeVersion": 1,
|
||||
"position": [160, 1400]
|
||||
},
|
||||
{
|
||||
"parameters": {
|
||||
"value": "={{ $json[\"Start_time\"].toString() }}",
|
||||
"options": {
|
||||
"fromFormat": "x",
|
||||
"toTimezone": "UTC"
|
||||
}
|
||||
},
|
||||
"id": "bc536546-4968-4b88-acaa-9a02bc013246",
|
||||
"name": "With toString",
|
||||
"type": "n8n-nodes-base.dateTime",
|
||||
"typeVersion": 1,
|
||||
"position": [160, 880]
|
||||
}
|
||||
],
|
||||
"pinData": {
|
||||
"Calculate Date: Format YYYY/MM/DD with Timezone Unix": [
|
||||
{
|
||||
"json": {
|
||||
"data": "1659312000000"
|
||||
}
|
||||
}
|
||||
],
|
||||
"Calculate Date: Format YYYY/MM/DD with Timezone with special zone": [
|
||||
{
|
||||
"json": {
|
||||
"data": "12-01-2022"
|
||||
}
|
||||
}
|
||||
],
|
||||
"Calculate Date: Add Day": [
|
||||
{
|
||||
"json": {
|
||||
"data": "2022-08-11T00:00:00.000Z"
|
||||
}
|
||||
}
|
||||
],
|
||||
"Calculate Date: Substract Day": [
|
||||
{
|
||||
"json": {
|
||||
"data": "2022-07-30T00:00:00.000Z"
|
||||
}
|
||||
}
|
||||
],
|
||||
"Calculate Date: Substract Quarter": [
|
||||
{
|
||||
"json": {
|
||||
"data": "2023-02-01T00:00:00.000Z"
|
||||
}
|
||||
}
|
||||
],
|
||||
"Calculate Date: Add months": [
|
||||
{
|
||||
"json": {
|
||||
"data": "2022-10-01T00:00:00.000Z"
|
||||
}
|
||||
}
|
||||
],
|
||||
"Calculate Date: Substract Months": [
|
||||
{
|
||||
"json": {
|
||||
"data": "2022-06-01T00:00:00.000Z"
|
||||
}
|
||||
}
|
||||
],
|
||||
"Calculate Date: Format YYYY/MM/DD": [
|
||||
{
|
||||
"json": {
|
||||
"data": "2022/08/01"
|
||||
}
|
||||
}
|
||||
],
|
||||
"Calculate Date: Format YYYY/MM/DD with Timezone": [
|
||||
{
|
||||
"json": {
|
||||
"data": "2022/07/31"
|
||||
}
|
||||
}
|
||||
],
|
||||
"Calculate Date: Format YYYY/MM/DD with Timezone1": [
|
||||
{
|
||||
"json": {
|
||||
"data": "2022/07/31"
|
||||
}
|
||||
}
|
||||
],
|
||||
"With toString": [
|
||||
{
|
||||
"json": {
|
||||
"Id": "18162",
|
||||
"Start_time": 1663801200000,
|
||||
"End_time": 1663804800000,
|
||||
"Room": " The Stadium",
|
||||
"data": "09/21/2022"
|
||||
}
|
||||
},
|
||||
{
|
||||
"json": {
|
||||
"Id": "18173",
|
||||
"Start_time": 1663797600000,
|
||||
"End_time": 1663801200000,
|
||||
"Room": " The Stadium",
|
||||
"data": "09/21/2022"
|
||||
}
|
||||
},
|
||||
{
|
||||
"json": {
|
||||
"Id": "18178",
|
||||
"Start_time": 1663804800000,
|
||||
"End_time": 1663808400000,
|
||||
"Room": " The Stadium",
|
||||
"data": "09/22/2022"
|
||||
}
|
||||
},
|
||||
{
|
||||
"json": {
|
||||
"Id": "18182",
|
||||
"Start_time": 1663801200000,
|
||||
"End_time": 1663804800000,
|
||||
"Room": " The Garden",
|
||||
"data": "09/21/2022"
|
||||
}
|
||||
}
|
||||
],
|
||||
"Fixed Value": [
|
||||
{
|
||||
"json": {
|
||||
"Id": "18162",
|
||||
"Start_time": 1663801200000,
|
||||
"End_time": 1663804800000,
|
||||
"Room": " The Stadium",
|
||||
"data": "09/21/2022"
|
||||
}
|
||||
},
|
||||
{
|
||||
"json": {
|
||||
"Id": "18173",
|
||||
"Start_time": 1663797600000,
|
||||
"End_time": 1663801200000,
|
||||
"Room": " The Stadium",
|
||||
"data": "09/21/2022"
|
||||
}
|
||||
},
|
||||
{
|
||||
"json": {
|
||||
"Id": "18178",
|
||||
"Start_time": 1663804800000,
|
||||
"End_time": 1663808400000,
|
||||
"Room": " The Stadium",
|
||||
"data": "09/21/2022"
|
||||
}
|
||||
},
|
||||
{
|
||||
"json": {
|
||||
"Id": "18182",
|
||||
"Start_time": 1663801200000,
|
||||
"End_time": 1663804800000,
|
||||
"Room": " The Garden",
|
||||
"data": "09/21/2022"
|
||||
}
|
||||
}
|
||||
],
|
||||
"Without toString()": [
|
||||
{
|
||||
"json": {
|
||||
"Id": "18162",
|
||||
"Start_time": 1663801200000,
|
||||
"End_time": 1663804800000,
|
||||
"Room": " The Stadium",
|
||||
"data": "09/21/2022"
|
||||
}
|
||||
},
|
||||
{
|
||||
"json": {
|
||||
"Id": "18173",
|
||||
"Start_time": 1663797600000,
|
||||
"End_time": 1663801200000,
|
||||
"Room": " The Stadium",
|
||||
"data": "09/21/2022"
|
||||
}
|
||||
},
|
||||
{
|
||||
"json": {
|
||||
"Id": "18178",
|
||||
"Start_time": 1663804800000,
|
||||
"End_time": 1663808400000,
|
||||
"Room": " The Stadium",
|
||||
"data": "09/22/2022"
|
||||
}
|
||||
},
|
||||
{
|
||||
"json": {
|
||||
"Id": "18182",
|
||||
"Start_time": 1663801200000,
|
||||
"End_time": 1663804800000,
|
||||
"Room": " The Garden",
|
||||
"data": "09/21/2022"
|
||||
}
|
||||
}
|
||||
],
|
||||
"parseInt on fixed": [
|
||||
{
|
||||
"json": {
|
||||
"Id": "18162",
|
||||
"Start_time": 1663801200000,
|
||||
"End_time": 1663804800000,
|
||||
"Room": " The Stadium",
|
||||
"data": "09/21/2022"
|
||||
}
|
||||
},
|
||||
{
|
||||
"json": {
|
||||
"Id": "18173",
|
||||
"Start_time": 1663797600000,
|
||||
"End_time": 1663801200000,
|
||||
"Room": " The Stadium",
|
||||
"data": "09/21/2022"
|
||||
}
|
||||
},
|
||||
{
|
||||
"json": {
|
||||
"Id": "18178",
|
||||
"Start_time": 1663804800000,
|
||||
"End_time": 1663808400000,
|
||||
"Room": " The Stadium",
|
||||
"data": "09/21/2022"
|
||||
}
|
||||
},
|
||||
{
|
||||
"json": {
|
||||
"Id": "18182",
|
||||
"Start_time": 1663801200000,
|
||||
"End_time": 1663804800000,
|
||||
"Room": " The Garden",
|
||||
"data": "09/21/2022"
|
||||
}
|
||||
}
|
||||
]
|
||||
},
|
||||
"connections": {
|
||||
"When clicking \"Execute Workflow\"": {
|
||||
"main": [
|
||||
[
|
||||
{
|
||||
"node": "Calculate Date: Add Day",
|
||||
"type": "main",
|
||||
"index": 0
|
||||
},
|
||||
{
|
||||
"node": "Calculate Date: Substract Day",
|
||||
"type": "main",
|
||||
"index": 0
|
||||
},
|
||||
{
|
||||
"node": "Calculate Date: Substract Quarter",
|
||||
"type": "main",
|
||||
"index": 0
|
||||
},
|
||||
{
|
||||
"node": "Calculate Date: Add months",
|
||||
"type": "main",
|
||||
"index": 0
|
||||
},
|
||||
{
|
||||
"node": "Calculate Date: Substract Months",
|
||||
"type": "main",
|
||||
"index": 0
|
||||
},
|
||||
{
|
||||
"node": "Calculate Date: Format YYYY/MM/DD",
|
||||
"type": "main",
|
||||
"index": 0
|
||||
},
|
||||
{
|
||||
"node": "Calculate Date: Format YYYY/MM/DD with Timezone",
|
||||
"type": "main",
|
||||
"index": 0
|
||||
},
|
||||
{
|
||||
"node": "Calculate Date: Format YYYY/MM/DD with Timezone1",
|
||||
"type": "main",
|
||||
"index": 0
|
||||
},
|
||||
{
|
||||
"node": "Calculate Date: Format YYYY/MM/DD with Timezone Unix",
|
||||
"type": "main",
|
||||
"index": 0
|
||||
},
|
||||
{
|
||||
"node": "Calculate Date: Format YYYY/MM/DD with Timezone with special zone",
|
||||
"type": "main",
|
||||
"index": 0
|
||||
},
|
||||
{
|
||||
"node": "Mock Data",
|
||||
"type": "main",
|
||||
"index": 0
|
||||
}
|
||||
]
|
||||
]
|
||||
},
|
||||
"Mock Data": {
|
||||
"main": [
|
||||
[
|
||||
{
|
||||
"node": "With toString",
|
||||
"type": "main",
|
||||
"index": 0
|
||||
},
|
||||
{
|
||||
"node": "Without toString()",
|
||||
"type": "main",
|
||||
"index": 0
|
||||
},
|
||||
{
|
||||
"node": "Fixed Value",
|
||||
"type": "main",
|
||||
"index": 0
|
||||
},
|
||||
{
|
||||
"node": "parseInt on fixed",
|
||||
"type": "main",
|
||||
"index": 0
|
||||
}
|
||||
]
|
||||
]
|
||||
}
|
||||
},
|
||||
"active": false,
|
||||
"settings": {},
|
||||
"versionId": "8ccd9e22-634a-4fc1-b41b-1a63062557e6",
|
||||
"id": "151",
|
||||
"meta": {
|
||||
"instanceId": "36203ea1ce3cef713fa25999bd9874ae26b9e4c2c3a90a365f2882a154d031d0"
|
||||
},
|
||||
"tags": []
|
||||
}
|
||||
@@ -0,0 +1,420 @@
|
||||
{
|
||||
"name": "My workflow 38",
|
||||
"nodes": [
|
||||
{
|
||||
"parameters": {},
|
||||
"id": "f1242de8-11fc-4849-a4a2-c82fa75731a7",
|
||||
"name": "When clicking \"Execute Workflow\"",
|
||||
"type": "n8n-nodes-base.manualTrigger",
|
||||
"typeVersion": 1,
|
||||
"position": [
|
||||
120,
|
||||
800
|
||||
]
|
||||
},
|
||||
{
|
||||
"parameters": {
|
||||
"values": {
|
||||
"number": [
|
||||
{
|
||||
"name": "dateMilis",
|
||||
"value": 1682918315906
|
||||
},
|
||||
{
|
||||
"name": "dateMilisFloat",
|
||||
"value": 1682918315.906
|
||||
},
|
||||
{
|
||||
"name": "dateUnix",
|
||||
"value": 1682918315
|
||||
}
|
||||
],
|
||||
"string": [
|
||||
{
|
||||
"name": "dateMilisStr",
|
||||
"value": "1682918315906"
|
||||
},
|
||||
{
|
||||
"name": "dateMilisFloatStr",
|
||||
"value": "1682918315.906"
|
||||
},
|
||||
{
|
||||
"name": "dateUnixStr",
|
||||
"value": "1682918315"
|
||||
}
|
||||
]
|
||||
},
|
||||
"options": {}
|
||||
},
|
||||
"id": "7208910f-fd33-42b9-bcf2-14bb0b0d157d",
|
||||
"name": "Set",
|
||||
"type": "n8n-nodes-base.set",
|
||||
"typeVersion": 2,
|
||||
"position": [
|
||||
320,
|
||||
800
|
||||
]
|
||||
},
|
||||
{
|
||||
"parameters": {
|
||||
"operation": "formatDate",
|
||||
"date": "={{ $json.dateMilis }}",
|
||||
"format": "yyyy/MM/dd",
|
||||
"outputFieldName": "data",
|
||||
"options": {}
|
||||
},
|
||||
"id": "fb66a2cc-95b9-4917-999b-847ab61a7938",
|
||||
"name": "Date & Time6",
|
||||
"type": "n8n-nodes-base.dateTime",
|
||||
"typeVersion": 2,
|
||||
"position": [
|
||||
700,
|
||||
360
|
||||
]
|
||||
},
|
||||
{
|
||||
"parameters": {
|
||||
"operation": "formatDate",
|
||||
"date": "={{ $json.dateMilisFloat }}",
|
||||
"format": "yyyy/MM/dd",
|
||||
"outputFieldName": "data",
|
||||
"options": {}
|
||||
},
|
||||
"id": "b94eb54a-1952-4f33-816a-8ffa47c7bb42",
|
||||
"name": "Date & Time",
|
||||
"type": "n8n-nodes-base.dateTime",
|
||||
"typeVersion": 2,
|
||||
"position": [
|
||||
700,
|
||||
720
|
||||
]
|
||||
},
|
||||
{
|
||||
"parameters": {
|
||||
"operation": "formatDate",
|
||||
"date": "={{ $json.dateUnix }}",
|
||||
"format": "yyyy/MM/dd",
|
||||
"outputFieldName": "data",
|
||||
"options": {}
|
||||
},
|
||||
"id": "7f0af92d-8064-4af0-8c2c-a21b70f69ac1",
|
||||
"name": "Date & Time1",
|
||||
"type": "n8n-nodes-base.dateTime",
|
||||
"typeVersion": 2,
|
||||
"position": [
|
||||
700,
|
||||
1080
|
||||
]
|
||||
},
|
||||
{
|
||||
"parameters": {},
|
||||
"id": "1e90549e-f4d4-46a1-bc9b-617befff2319",
|
||||
"name": "No Operation, do nothing",
|
||||
"type": "n8n-nodes-base.noOp",
|
||||
"typeVersion": 1,
|
||||
"position": [
|
||||
900,
|
||||
360
|
||||
]
|
||||
},
|
||||
{
|
||||
"parameters": {},
|
||||
"id": "ec07d232-e513-4f09-8cb1-e8e4853bcebc",
|
||||
"name": "No Operation, do nothing1",
|
||||
"type": "n8n-nodes-base.noOp",
|
||||
"typeVersion": 1,
|
||||
"position": [
|
||||
900,
|
||||
720
|
||||
]
|
||||
},
|
||||
{
|
||||
"parameters": {},
|
||||
"id": "f9839c73-ed5e-4ae0-bc1e-5a1914ac8b55",
|
||||
"name": "No Operation, do nothing2",
|
||||
"type": "n8n-nodes-base.noOp",
|
||||
"typeVersion": 1,
|
||||
"position": [
|
||||
900,
|
||||
1080
|
||||
]
|
||||
},
|
||||
{
|
||||
"parameters": {
|
||||
"operation": "formatDate",
|
||||
"date": "={{ $json.dateMilis }}",
|
||||
"format": "yyyy/MM/dd",
|
||||
"outputFieldName": "data",
|
||||
"options": {
|
||||
"includeInputFields": true
|
||||
}
|
||||
},
|
||||
"id": "bfce6276-2de4-4783-bc7f-d82fab23c2af",
|
||||
"name": "Date & Time7",
|
||||
"type": "n8n-nodes-base.dateTime",
|
||||
"typeVersion": 2,
|
||||
"position": [
|
||||
700,
|
||||
500
|
||||
]
|
||||
},
|
||||
{
|
||||
"parameters": {
|
||||
"operation": "formatDate",
|
||||
"date": "={{ $json.dateMilisFloat }}",
|
||||
"format": "yyyy/MM/dd",
|
||||
"outputFieldName": "data",
|
||||
"options": {
|
||||
"includeInputFields": true
|
||||
}
|
||||
},
|
||||
"id": "a7aad9c9-20ff-4353-9445-80366fad9431",
|
||||
"name": "Date & Time2",
|
||||
"type": "n8n-nodes-base.dateTime",
|
||||
"typeVersion": 2,
|
||||
"position": [
|
||||
700,
|
||||
860
|
||||
]
|
||||
},
|
||||
{
|
||||
"parameters": {
|
||||
"operation": "formatDate",
|
||||
"date": "={{ $json.dateUnix }}",
|
||||
"format": "yyyy/MM/dd",
|
||||
"outputFieldName": "data",
|
||||
"options": {
|
||||
"includeInputFields": true
|
||||
}
|
||||
},
|
||||
"id": "3b9e3ad7-0d00-4598-b796-23bb206e75db",
|
||||
"name": "Date & Time3",
|
||||
"type": "n8n-nodes-base.dateTime",
|
||||
"typeVersion": 2,
|
||||
"position": [
|
||||
700,
|
||||
1240
|
||||
]
|
||||
},
|
||||
{
|
||||
"parameters": {},
|
||||
"id": "8a3cdde0-b1de-46dc-a8c6-74cc174fd4a1",
|
||||
"name": "No Operation, do nothing3",
|
||||
"type": "n8n-nodes-base.noOp",
|
||||
"typeVersion": 1,
|
||||
"position": [
|
||||
900,
|
||||
1240
|
||||
]
|
||||
},
|
||||
{
|
||||
"parameters": {},
|
||||
"id": "54b4d584-0874-411b-9c98-8194c0928588",
|
||||
"name": "No Operation, do nothing4",
|
||||
"type": "n8n-nodes-base.noOp",
|
||||
"typeVersion": 1,
|
||||
"position": [
|
||||
900,
|
||||
860
|
||||
]
|
||||
},
|
||||
{
|
||||
"parameters": {},
|
||||
"id": "4a4e7647-6c6e-4a24-9032-829e5f495337",
|
||||
"name": "No Operation, do nothing5",
|
||||
"type": "n8n-nodes-base.noOp",
|
||||
"typeVersion": 1,
|
||||
"position": [
|
||||
900,
|
||||
500
|
||||
]
|
||||
}
|
||||
],
|
||||
"pinData": {
|
||||
"No Operation, do nothing2": [
|
||||
{
|
||||
"json": {
|
||||
"data": "2023/05/01"
|
||||
}
|
||||
}
|
||||
],
|
||||
"No Operation, do nothing1": [
|
||||
{
|
||||
"json": {
|
||||
"data": "2023/05/01"
|
||||
}
|
||||
}
|
||||
],
|
||||
"No Operation, do nothing": [
|
||||
{
|
||||
"json": {
|
||||
"data": "2023/05/01"
|
||||
}
|
||||
}
|
||||
],
|
||||
"No Operation, do nothing5": [
|
||||
{
|
||||
"json": {
|
||||
"dateMilis": 1682918315906,
|
||||
"dateMilisFloat": 1682918315.906,
|
||||
"dateUnix": 1682918315,
|
||||
"dateMilisStr": "1682918315906",
|
||||
"dateMilisFloatStr": "1682918315.906",
|
||||
"dateUnixStr": "1682918315",
|
||||
"data": "2023/05/01"
|
||||
}
|
||||
}
|
||||
],
|
||||
"No Operation, do nothing4": [
|
||||
{
|
||||
"json": {
|
||||
"dateMilis": 1682918315906,
|
||||
"dateMilisFloat": 1682918315.906,
|
||||
"dateUnix": 1682918315,
|
||||
"dateMilisStr": "1682918315906",
|
||||
"dateMilisFloatStr": "1682918315.906",
|
||||
"dateUnixStr": "1682918315",
|
||||
"data": "2023/05/01"
|
||||
}
|
||||
}
|
||||
],
|
||||
"No Operation, do nothing3": [
|
||||
{
|
||||
"json": {
|
||||
"dateMilis": 1682918315906,
|
||||
"dateMilisFloat": 1682918315.906,
|
||||
"dateUnix": 1682918315,
|
||||
"dateMilisStr": "1682918315906",
|
||||
"dateMilisFloatStr": "1682918315.906",
|
||||
"dateUnixStr": "1682918315",
|
||||
"data": "2023/05/01"
|
||||
}
|
||||
}
|
||||
]
|
||||
},
|
||||
"connections": {
|
||||
"When clicking \"Execute Workflow\"": {
|
||||
"main": [
|
||||
[
|
||||
{
|
||||
"node": "Set",
|
||||
"type": "main",
|
||||
"index": 0
|
||||
}
|
||||
]
|
||||
]
|
||||
},
|
||||
"Set": {
|
||||
"main": [
|
||||
[
|
||||
{
|
||||
"node": "Date & Time6",
|
||||
"type": "main",
|
||||
"index": 0
|
||||
},
|
||||
{
|
||||
"node": "Date & Time",
|
||||
"type": "main",
|
||||
"index": 0
|
||||
},
|
||||
{
|
||||
"node": "Date & Time1",
|
||||
"type": "main",
|
||||
"index": 0
|
||||
},
|
||||
{
|
||||
"node": "Date & Time7",
|
||||
"type": "main",
|
||||
"index": 0
|
||||
},
|
||||
{
|
||||
"node": "Date & Time2",
|
||||
"type": "main",
|
||||
"index": 0
|
||||
},
|
||||
{
|
||||
"node": "Date & Time3",
|
||||
"type": "main",
|
||||
"index": 0
|
||||
}
|
||||
]
|
||||
]
|
||||
},
|
||||
"Date & Time6": {
|
||||
"main": [
|
||||
[
|
||||
{
|
||||
"node": "No Operation, do nothing",
|
||||
"type": "main",
|
||||
"index": 0
|
||||
}
|
||||
]
|
||||
]
|
||||
},
|
||||
"Date & Time1": {
|
||||
"main": [
|
||||
[
|
||||
{
|
||||
"node": "No Operation, do nothing2",
|
||||
"type": "main",
|
||||
"index": 0
|
||||
}
|
||||
]
|
||||
]
|
||||
},
|
||||
"Date & Time": {
|
||||
"main": [
|
||||
[
|
||||
{
|
||||
"node": "No Operation, do nothing1",
|
||||
"type": "main",
|
||||
"index": 0
|
||||
}
|
||||
]
|
||||
]
|
||||
},
|
||||
"Date & Time3": {
|
||||
"main": [
|
||||
[
|
||||
{
|
||||
"node": "No Operation, do nothing3",
|
||||
"type": "main",
|
||||
"index": 0
|
||||
}
|
||||
]
|
||||
]
|
||||
},
|
||||
"Date & Time2": {
|
||||
"main": [
|
||||
[
|
||||
{
|
||||
"node": "No Operation, do nothing4",
|
||||
"type": "main",
|
||||
"index": 0
|
||||
}
|
||||
]
|
||||
]
|
||||
},
|
||||
"Date & Time7": {
|
||||
"main": [
|
||||
[
|
||||
{
|
||||
"node": "No Operation, do nothing5",
|
||||
"type": "main",
|
||||
"index": 0
|
||||
}
|
||||
]
|
||||
]
|
||||
}
|
||||
},
|
||||
"active": false,
|
||||
"settings": {
|
||||
"executionOrder": "v1"
|
||||
},
|
||||
"versionId": "419a6926-5d06-4ba5-b261-410e124996de",
|
||||
"id": "hW8KyOyaCN5fGQru",
|
||||
"meta": {
|
||||
"instanceId": "b888bd11cd1ddbb95450babf3e199556799d999b896f650de768b8370ee50363"
|
||||
},
|
||||
"tags": []
|
||||
}
|
||||
@@ -0,0 +1,165 @@
|
||||
{
|
||||
"name": "My workflow 10",
|
||||
"nodes": [
|
||||
{
|
||||
"parameters": {},
|
||||
"id": "4d3b2f7b-1ae9-432d-b765-c6134cd11afc",
|
||||
"name": "When clicking \"Execute Workflow\"",
|
||||
"type": "n8n-nodes-base.manualTrigger",
|
||||
"typeVersion": 1,
|
||||
"position": [-60, 2060]
|
||||
},
|
||||
{
|
||||
"parameters": {
|
||||
"value": "={{ DateTime.fromISO($json.testData) }}",
|
||||
"toFormat": "X",
|
||||
"options": {
|
||||
"toTimezone": "UTC"
|
||||
}
|
||||
},
|
||||
"id": "31ad53db-5cfd-44e5-917b-b90105ae687d",
|
||||
"name": "Date & Time",
|
||||
"type": "n8n-nodes-base.dateTime",
|
||||
"typeVersion": 1,
|
||||
"position": [400, 1960]
|
||||
},
|
||||
{
|
||||
"parameters": {
|
||||
"value": "={{ DateTime.fromISO($json.testData).minus({days:1}) }}",
|
||||
"toFormat": "X",
|
||||
"options": {
|
||||
"toTimezone": "UTC"
|
||||
}
|
||||
},
|
||||
"id": "f959c146-2cd3-4bc5-aa55-5b974466ba90",
|
||||
"name": "Date & Time1",
|
||||
"type": "n8n-nodes-base.dateTime",
|
||||
"typeVersion": 1,
|
||||
"position": [400, 2180]
|
||||
},
|
||||
{
|
||||
"parameters": {
|
||||
"value": "={{ Number($json.data) }}",
|
||||
"toFormat": "YYYY-MM-DD",
|
||||
"options": {
|
||||
"toTimezone": "UTC"
|
||||
}
|
||||
},
|
||||
"id": "8bf5b635-607e-4207-8b0e-66f0540b103c",
|
||||
"name": "Date & Time2",
|
||||
"type": "n8n-nodes-base.dateTime",
|
||||
"typeVersion": 1,
|
||||
"position": [620, 1960]
|
||||
},
|
||||
{
|
||||
"parameters": {
|
||||
"value": "={{ Number($json.data) }}",
|
||||
"toFormat": "YYYY-MM-DD",
|
||||
"options": {
|
||||
"toTimezone": "UTC"
|
||||
}
|
||||
},
|
||||
"id": "350ce053-d415-4a7d-8447-6d7c73758f35",
|
||||
"name": "Date & Time3",
|
||||
"type": "n8n-nodes-base.dateTime",
|
||||
"typeVersion": 1,
|
||||
"position": [620, 2180]
|
||||
},
|
||||
{
|
||||
"parameters": {
|
||||
"keepOnlySet": true,
|
||||
"values": {
|
||||
"string": [
|
||||
{
|
||||
"name": "testData",
|
||||
"value": "2023-03-31T06:31:01.000"
|
||||
}
|
||||
]
|
||||
},
|
||||
"options": {}
|
||||
},
|
||||
"id": "b57950a6-3a6a-4e23-8c3b-16abe12bfe16",
|
||||
"name": "Set",
|
||||
"type": "n8n-nodes-base.set",
|
||||
"typeVersion": 2,
|
||||
"position": [140, 2060]
|
||||
}
|
||||
],
|
||||
"pinData": {
|
||||
"Date & Time2": [
|
||||
{
|
||||
"json": {
|
||||
"testData": "2023-03-31T06:31:01.000",
|
||||
"data": "2023-03-31"
|
||||
}
|
||||
}
|
||||
],
|
||||
"Date & Time3": [
|
||||
{
|
||||
"json": {
|
||||
"testData": "2023-03-31T06:31:01.000",
|
||||
"data": "2023-03-30"
|
||||
}
|
||||
}
|
||||
]
|
||||
},
|
||||
"connections": {
|
||||
"When clicking \"Execute Workflow\"": {
|
||||
"main": [
|
||||
[
|
||||
{
|
||||
"node": "Set",
|
||||
"type": "main",
|
||||
"index": 0
|
||||
}
|
||||
]
|
||||
]
|
||||
},
|
||||
"Date & Time": {
|
||||
"main": [
|
||||
[
|
||||
{
|
||||
"node": "Date & Time2",
|
||||
"type": "main",
|
||||
"index": 0
|
||||
}
|
||||
]
|
||||
]
|
||||
},
|
||||
"Date & Time1": {
|
||||
"main": [
|
||||
[
|
||||
{
|
||||
"node": "Date & Time3",
|
||||
"type": "main",
|
||||
"index": 0
|
||||
}
|
||||
]
|
||||
]
|
||||
},
|
||||
"Set": {
|
||||
"main": [
|
||||
[
|
||||
{
|
||||
"node": "Date & Time",
|
||||
"type": "main",
|
||||
"index": 0
|
||||
},
|
||||
{
|
||||
"node": "Date & Time1",
|
||||
"type": "main",
|
||||
"index": 0
|
||||
}
|
||||
]
|
||||
]
|
||||
}
|
||||
},
|
||||
"active": false,
|
||||
"settings": {},
|
||||
"versionId": "ff99618e-6e8e-49d8-b899-021caff6d01d",
|
||||
"id": "151",
|
||||
"meta": {
|
||||
"instanceId": "36203ea1ce3cef713fa25999bd9874ae26b9e4c2c3a90a365f2882a154d031d0"
|
||||
},
|
||||
"tags": []
|
||||
}
|
||||
@@ -0,0 +1,86 @@
|
||||
{
|
||||
"name": "Null Date",
|
||||
"nodes": [
|
||||
{
|
||||
"parameters": {},
|
||||
"id": "62bb450c-f2e3-41c9-9894-a954d2c5e115",
|
||||
"name": "When clicking \"Execute Workflow\"",
|
||||
"type": "n8n-nodes-base.manualTrigger",
|
||||
"typeVersion": 1,
|
||||
"position": [1600, 740]
|
||||
},
|
||||
{
|
||||
"parameters": {
|
||||
"data": {
|
||||
"date": null
|
||||
}
|
||||
},
|
||||
"id": "47e4ce5b-2365-4987-a058-ae21964d135d",
|
||||
"name": "Code",
|
||||
"type": "n8n-nodes-testing.testData",
|
||||
"typeVersion": 1,
|
||||
"position": [1820, 740]
|
||||
},
|
||||
{
|
||||
"parameters": {
|
||||
"operation": "formatDate",
|
||||
"date": "={{ $json.date }}",
|
||||
"options": {}
|
||||
},
|
||||
"id": "9af21b91-9db6-40cd-98ee-ee969eb0a348",
|
||||
"name": "Date & Time",
|
||||
"type": "n8n-nodes-base.dateTime",
|
||||
"typeVersion": 2,
|
||||
"position": [2040, 740]
|
||||
}
|
||||
],
|
||||
"pinData": {
|
||||
"Date & Time": [
|
||||
{
|
||||
"json": {
|
||||
"formattedDate": null
|
||||
}
|
||||
}
|
||||
],
|
||||
"Code": [
|
||||
{
|
||||
"json": {
|
||||
"date": null
|
||||
}
|
||||
}
|
||||
]
|
||||
},
|
||||
"connections": {
|
||||
"When clicking \"Execute Workflow\"": {
|
||||
"main": [
|
||||
[
|
||||
{
|
||||
"node": "Code",
|
||||
"type": "main",
|
||||
"index": 0
|
||||
}
|
||||
]
|
||||
]
|
||||
},
|
||||
"Code": {
|
||||
"main": [
|
||||
[
|
||||
{
|
||||
"node": "Date & Time",
|
||||
"type": "main",
|
||||
"index": 0
|
||||
}
|
||||
]
|
||||
]
|
||||
}
|
||||
},
|
||||
"active": false,
|
||||
"settings": {
|
||||
"executionOrder": "v1"
|
||||
},
|
||||
"versionId": "",
|
||||
"meta": {
|
||||
"instanceId": "78577815012af39cf16dad7a787b0898c42fb7514b8a7f99b2136862c2af502c"
|
||||
},
|
||||
"tags": []
|
||||
}
|
||||
@@ -0,0 +1,393 @@
|
||||
{
|
||||
"name": "date time",
|
||||
"nodes": [
|
||||
{
|
||||
"parameters": {},
|
||||
"id": "7192e181-4384-430d-a25c-25beb0ae6b1f",
|
||||
"name": "When clicking \"Execute Workflow\"",
|
||||
"type": "n8n-nodes-base.manualTrigger",
|
||||
"typeVersion": 1,
|
||||
"position": [-100, 1040]
|
||||
},
|
||||
{
|
||||
"parameters": {
|
||||
"values": {
|
||||
"number": [
|
||||
{
|
||||
"name": "dateMilis",
|
||||
"value": 1682918315906
|
||||
},
|
||||
{
|
||||
"name": "dateMilisFloat",
|
||||
"value": 1682918315.906
|
||||
},
|
||||
{
|
||||
"name": "dateUnix",
|
||||
"value": 1682918315
|
||||
}
|
||||
],
|
||||
"string": [
|
||||
{
|
||||
"name": "dateMilisStr",
|
||||
"value": "1682918315906"
|
||||
},
|
||||
{
|
||||
"name": "dateMilisFloatStr",
|
||||
"value": "1682918315.906"
|
||||
},
|
||||
{
|
||||
"name": "dateUnixStr",
|
||||
"value": "1682918315"
|
||||
}
|
||||
]
|
||||
},
|
||||
"options": {}
|
||||
},
|
||||
"id": "dc933b29-a770-43b8-aa20-a8e82b0d034f",
|
||||
"name": "Set",
|
||||
"type": "n8n-nodes-base.set",
|
||||
"typeVersion": 2,
|
||||
"position": [60, 1040]
|
||||
},
|
||||
{
|
||||
"parameters": {
|
||||
"value": "={{ $json.dateMilis }}",
|
||||
"options": {}
|
||||
},
|
||||
"id": "2bcbc9d8-af2f-4c44-b47e-80a9462350d0",
|
||||
"name": "Date & Time",
|
||||
"type": "n8n-nodes-base.dateTime",
|
||||
"typeVersion": 1,
|
||||
"position": [360, 560]
|
||||
},
|
||||
{
|
||||
"parameters": {
|
||||
"keepOnlySet": true,
|
||||
"values": {
|
||||
"string": [
|
||||
{
|
||||
"name": "data",
|
||||
"value": "={{ $json.data }}"
|
||||
}
|
||||
]
|
||||
},
|
||||
"options": {}
|
||||
},
|
||||
"id": "c1b947a8-45c6-4c6a-b4ce-467d57de6d50",
|
||||
"name": "Set1",
|
||||
"type": "n8n-nodes-base.set",
|
||||
"typeVersion": 2,
|
||||
"position": [580, 560]
|
||||
},
|
||||
{
|
||||
"parameters": {
|
||||
"value": "={{ $json.dateMilisFloat }}",
|
||||
"options": {}
|
||||
},
|
||||
"id": "a91fc3d9-afb8-4c78-ad0b-2078639708da",
|
||||
"name": "Date & Time1",
|
||||
"type": "n8n-nodes-base.dateTime",
|
||||
"typeVersion": 1,
|
||||
"position": [360, 740]
|
||||
},
|
||||
{
|
||||
"parameters": {
|
||||
"keepOnlySet": true,
|
||||
"values": {
|
||||
"string": [
|
||||
{
|
||||
"name": "data",
|
||||
"value": "={{ $json.data }}"
|
||||
}
|
||||
]
|
||||
},
|
||||
"options": {}
|
||||
},
|
||||
"id": "370b58aa-555f-4dc7-9c48-564bddfcbe33",
|
||||
"name": "Set2",
|
||||
"type": "n8n-nodes-base.set",
|
||||
"typeVersion": 2,
|
||||
"position": [580, 740]
|
||||
},
|
||||
{
|
||||
"parameters": {
|
||||
"value": "={{ $json.dateUnix }}",
|
||||
"options": {}
|
||||
},
|
||||
"id": "91d1e77d-3d25-4e87-9af8-f756ace4abcf",
|
||||
"name": "Date & Time2",
|
||||
"type": "n8n-nodes-base.dateTime",
|
||||
"typeVersion": 1,
|
||||
"position": [360, 940]
|
||||
},
|
||||
{
|
||||
"parameters": {
|
||||
"keepOnlySet": true,
|
||||
"values": {
|
||||
"string": [
|
||||
{
|
||||
"name": "data",
|
||||
"value": "={{ $json.data }}"
|
||||
}
|
||||
]
|
||||
},
|
||||
"options": {}
|
||||
},
|
||||
"id": "77cdf5fa-641e-46e1-8cb9-00160773b4b2",
|
||||
"name": "Set3",
|
||||
"type": "n8n-nodes-base.set",
|
||||
"typeVersion": 2,
|
||||
"position": [580, 940]
|
||||
},
|
||||
{
|
||||
"parameters": {
|
||||
"value": "={{ $json.dateMilisStr }}",
|
||||
"options": {}
|
||||
},
|
||||
"id": "084e7b19-f03e-42a9-b4df-865f2f6610de",
|
||||
"name": "Date & Time3",
|
||||
"type": "n8n-nodes-base.dateTime",
|
||||
"typeVersion": 1,
|
||||
"position": [360, 1120]
|
||||
},
|
||||
{
|
||||
"parameters": {
|
||||
"keepOnlySet": true,
|
||||
"values": {
|
||||
"string": [
|
||||
{
|
||||
"name": "data",
|
||||
"value": "={{ $json.data }}"
|
||||
}
|
||||
]
|
||||
},
|
||||
"options": {}
|
||||
},
|
||||
"id": "eb46b668-2ebc-47ee-adca-a8f99205ac26",
|
||||
"name": "Set4",
|
||||
"type": "n8n-nodes-base.set",
|
||||
"typeVersion": 2,
|
||||
"position": [580, 1120]
|
||||
},
|
||||
{
|
||||
"parameters": {
|
||||
"value": "={{ $json.dateMilisFloatStr }}",
|
||||
"options": {}
|
||||
},
|
||||
"id": "9cb46fb5-e6e4-4fb3-859a-8cd26bebf1c9",
|
||||
"name": "Date & Time4",
|
||||
"type": "n8n-nodes-base.dateTime",
|
||||
"typeVersion": 1,
|
||||
"position": [360, 1300]
|
||||
},
|
||||
{
|
||||
"parameters": {
|
||||
"keepOnlySet": true,
|
||||
"values": {
|
||||
"string": [
|
||||
{
|
||||
"name": "data",
|
||||
"value": "={{ $json.data }}"
|
||||
}
|
||||
]
|
||||
},
|
||||
"options": {}
|
||||
},
|
||||
"id": "0d09dc35-d572-41f5-984c-30a66184b80a",
|
||||
"name": "Set5",
|
||||
"type": "n8n-nodes-base.set",
|
||||
"typeVersion": 2,
|
||||
"position": [580, 1300]
|
||||
},
|
||||
{
|
||||
"parameters": {
|
||||
"value": "={{ $json.dateUnixStr }}",
|
||||
"options": {}
|
||||
},
|
||||
"id": "208e26b1-db01-417b-b21f-fcb8198a1e27",
|
||||
"name": "Date & Time5",
|
||||
"type": "n8n-nodes-base.dateTime",
|
||||
"typeVersion": 1,
|
||||
"position": [360, 1480]
|
||||
},
|
||||
{
|
||||
"parameters": {
|
||||
"keepOnlySet": true,
|
||||
"values": {
|
||||
"string": [
|
||||
{
|
||||
"name": "data",
|
||||
"value": "={{ $json.data }}"
|
||||
}
|
||||
]
|
||||
},
|
||||
"options": {}
|
||||
},
|
||||
"id": "1076029a-91a7-4121-aadc-e9dde57b3d56",
|
||||
"name": "Set6",
|
||||
"type": "n8n-nodes-base.set",
|
||||
"typeVersion": 2,
|
||||
"position": [580, 1480]
|
||||
}
|
||||
],
|
||||
"pinData": {
|
||||
"Set1": [
|
||||
{
|
||||
"json": {
|
||||
"data": "05/01/2023"
|
||||
}
|
||||
}
|
||||
],
|
||||
"Set2": [
|
||||
{
|
||||
"json": {
|
||||
"data": "05/01/2023"
|
||||
}
|
||||
}
|
||||
],
|
||||
"Set4": [
|
||||
{
|
||||
"json": {
|
||||
"data": "05/01/2023"
|
||||
}
|
||||
}
|
||||
],
|
||||
"Set5": [
|
||||
{
|
||||
"json": {
|
||||
"data": "05/01/2023"
|
||||
}
|
||||
}
|
||||
],
|
||||
"Set6": [
|
||||
{
|
||||
"json": {
|
||||
"data": "05/01/2023"
|
||||
}
|
||||
}
|
||||
]
|
||||
},
|
||||
"connections": {
|
||||
"When clicking \"Execute Workflow\"": {
|
||||
"main": [
|
||||
[
|
||||
{
|
||||
"node": "Set",
|
||||
"type": "main",
|
||||
"index": 0
|
||||
}
|
||||
]
|
||||
]
|
||||
},
|
||||
"Set": {
|
||||
"main": [
|
||||
[
|
||||
{
|
||||
"node": "Date & Time",
|
||||
"type": "main",
|
||||
"index": 0
|
||||
},
|
||||
{
|
||||
"node": "Date & Time1",
|
||||
"type": "main",
|
||||
"index": 0
|
||||
},
|
||||
{
|
||||
"node": "Date & Time2",
|
||||
"type": "main",
|
||||
"index": 0
|
||||
},
|
||||
{
|
||||
"node": "Date & Time3",
|
||||
"type": "main",
|
||||
"index": 0
|
||||
},
|
||||
{
|
||||
"node": "Date & Time4",
|
||||
"type": "main",
|
||||
"index": 0
|
||||
},
|
||||
{
|
||||
"node": "Date & Time5",
|
||||
"type": "main",
|
||||
"index": 0
|
||||
}
|
||||
]
|
||||
]
|
||||
},
|
||||
"Date & Time": {
|
||||
"main": [
|
||||
[
|
||||
{
|
||||
"node": "Set1",
|
||||
"type": "main",
|
||||
"index": 0
|
||||
}
|
||||
]
|
||||
]
|
||||
},
|
||||
"Date & Time1": {
|
||||
"main": [
|
||||
[
|
||||
{
|
||||
"node": "Set2",
|
||||
"type": "main",
|
||||
"index": 0
|
||||
}
|
||||
]
|
||||
]
|
||||
},
|
||||
"Date & Time2": {
|
||||
"main": [
|
||||
[
|
||||
{
|
||||
"node": "Set3",
|
||||
"type": "main",
|
||||
"index": 0
|
||||
}
|
||||
]
|
||||
]
|
||||
},
|
||||
"Date & Time3": {
|
||||
"main": [
|
||||
[
|
||||
{
|
||||
"node": "Set4",
|
||||
"type": "main",
|
||||
"index": 0
|
||||
}
|
||||
]
|
||||
]
|
||||
},
|
||||
"Date & Time4": {
|
||||
"main": [
|
||||
[
|
||||
{
|
||||
"node": "Set5",
|
||||
"type": "main",
|
||||
"index": 0
|
||||
}
|
||||
]
|
||||
]
|
||||
},
|
||||
"Date & Time5": {
|
||||
"main": [
|
||||
[
|
||||
{
|
||||
"node": "Set6",
|
||||
"type": "main",
|
||||
"index": 0
|
||||
}
|
||||
]
|
||||
]
|
||||
}
|
||||
},
|
||||
"active": false,
|
||||
"settings": {},
|
||||
"versionId": "d11f32bd-0d35-4aeb-9b0c-c4cac94f6445",
|
||||
"id": "12",
|
||||
"meta": {
|
||||
"instanceId": "6ebec4953fe56f1c009e7c3b107578b375137523af057073c0b5da17350651bd"
|
||||
},
|
||||
"tags": []
|
||||
}
|
||||
@@ -0,0 +1,352 @@
|
||||
{
|
||||
"name": "dateTime overhaul",
|
||||
"nodes": [
|
||||
{
|
||||
"parameters": {},
|
||||
"id": "4ef93910-a6f8-43e2-bba7-8319ef62f9ee",
|
||||
"name": "When clicking \"Execute Workflow\"",
|
||||
"type": "n8n-nodes-base.manualTrigger",
|
||||
"typeVersion": 1,
|
||||
"position": [260, 820]
|
||||
},
|
||||
{
|
||||
"parameters": {
|
||||
"values": {
|
||||
"number": [
|
||||
{
|
||||
"name": "dateMilis",
|
||||
"value": 1682918315906
|
||||
},
|
||||
{
|
||||
"name": "dateMilisFloat",
|
||||
"value": 1682918315.906
|
||||
},
|
||||
{
|
||||
"name": "dateUnix",
|
||||
"value": 1682918315
|
||||
}
|
||||
],
|
||||
"string": [
|
||||
{
|
||||
"name": "dateMilisStr",
|
||||
"value": "1682918315906"
|
||||
},
|
||||
{
|
||||
"name": "dateMilisFloatStr",
|
||||
"value": "1682918315.906"
|
||||
},
|
||||
{
|
||||
"name": "dateUnixStr",
|
||||
"value": "1682918315"
|
||||
}
|
||||
]
|
||||
},
|
||||
"options": {}
|
||||
},
|
||||
"id": "1d9bc8b7-9c8d-40c8-92f2-e94ed50d0ae5",
|
||||
"name": "Set",
|
||||
"type": "n8n-nodes-base.set",
|
||||
"typeVersion": 2,
|
||||
"position": [420, 820]
|
||||
},
|
||||
{
|
||||
"parameters": {
|
||||
"operation": "formatDate",
|
||||
"date": "={{ $json.dateMilis }}",
|
||||
"format": "yyyy/MM/dd",
|
||||
"outputFieldName": "data",
|
||||
"additionalFields": {}
|
||||
},
|
||||
"id": "c07b9cbd-4aeb-4267-a1d3-b45ecadbd1cb",
|
||||
"name": "Date & Time6",
|
||||
"type": "n8n-nodes-base.dateTime",
|
||||
"typeVersion": 2,
|
||||
"position": [680, 640]
|
||||
},
|
||||
{
|
||||
"parameters": {
|
||||
"operation": "formatDate",
|
||||
"date": "={{ $json.dateMilisFloat }}",
|
||||
"format": "yyyy/MM/dd",
|
||||
"outputFieldName": "data",
|
||||
"additionalFields": {}
|
||||
},
|
||||
"id": "a5b7bb44-63e2-4b71-ad91-55bac329e3f6",
|
||||
"name": "Date & Time",
|
||||
"type": "n8n-nodes-base.dateTime",
|
||||
"typeVersion": 2,
|
||||
"position": [680, 780]
|
||||
},
|
||||
{
|
||||
"parameters": {
|
||||
"operation": "formatDate",
|
||||
"date": "={{ $json.dateUnix }}",
|
||||
"format": "yyyy/MM/dd",
|
||||
"outputFieldName": "data",
|
||||
"additionalFields": {}
|
||||
},
|
||||
"id": "1306d282-b5f8-4a54-8834-6207ecff65f7",
|
||||
"name": "Date & Time1",
|
||||
"type": "n8n-nodes-base.dateTime",
|
||||
"typeVersion": 2,
|
||||
"position": [680, 940]
|
||||
},
|
||||
{
|
||||
"parameters": {
|
||||
"operation": "formatDate",
|
||||
"date": "={{ $json.dateMilisStr }}",
|
||||
"format": "yyyy/MM/dd",
|
||||
"outputFieldName": "data",
|
||||
"additionalFields": {}
|
||||
},
|
||||
"id": "4823c095-1921-406e-9957-a75521bca1e5",
|
||||
"name": "Date & Time2",
|
||||
"type": "n8n-nodes-base.dateTime",
|
||||
"typeVersion": 2,
|
||||
"position": [680, 1080]
|
||||
},
|
||||
{
|
||||
"parameters": {
|
||||
"operation": "formatDate",
|
||||
"date": "={{ $json.dateMilisFloatStr }}",
|
||||
"format": "yyyy/MM/dd",
|
||||
"outputFieldName": "data",
|
||||
"additionalFields": {}
|
||||
},
|
||||
"id": "d209ac18-9935-4452-825a-42aa90daaaa5",
|
||||
"name": "Date & Time3",
|
||||
"type": "n8n-nodes-base.dateTime",
|
||||
"typeVersion": 2,
|
||||
"position": [680, 1220]
|
||||
},
|
||||
{
|
||||
"parameters": {
|
||||
"operation": "formatDate",
|
||||
"date": "={{ $json.dateUnixStr }}",
|
||||
"format": "yyyy/MM/dd",
|
||||
"outputFieldName": "data",
|
||||
"additionalFields": {}
|
||||
},
|
||||
"id": "b7065dfb-ae7e-4828-a5ea-e9c313302944",
|
||||
"name": "Date & Time4",
|
||||
"type": "n8n-nodes-base.dateTime",
|
||||
"typeVersion": 2,
|
||||
"position": [680, 1380]
|
||||
},
|
||||
{
|
||||
"parameters": {},
|
||||
"id": "5ae1bb29-d19e-4e3d-af11-ccc53ee23bfb",
|
||||
"name": "No Operation, do nothing",
|
||||
"type": "n8n-nodes-base.noOp",
|
||||
"typeVersion": 1,
|
||||
"position": [900, 640]
|
||||
},
|
||||
{
|
||||
"parameters": {},
|
||||
"id": "8716cc32-d4a6-48d6-af5d-e15646006dd8",
|
||||
"name": "No Operation, do nothing1",
|
||||
"type": "n8n-nodes-base.noOp",
|
||||
"typeVersion": 1,
|
||||
"position": [900, 780]
|
||||
},
|
||||
{
|
||||
"parameters": {},
|
||||
"id": "88f0247d-ecc0-49a2-8bae-4e7b99ae8611",
|
||||
"name": "No Operation, do nothing2",
|
||||
"type": "n8n-nodes-base.noOp",
|
||||
"typeVersion": 1,
|
||||
"position": [900, 920]
|
||||
},
|
||||
{
|
||||
"parameters": {},
|
||||
"id": "99a04c1d-5426-446e-9171-2d12a5b14a13",
|
||||
"name": "No Operation, do nothing3",
|
||||
"type": "n8n-nodes-base.noOp",
|
||||
"typeVersion": 1,
|
||||
"position": [900, 1060]
|
||||
},
|
||||
{
|
||||
"parameters": {},
|
||||
"id": "923e317f-3e7b-4609-883d-c630034bd20c",
|
||||
"name": "No Operation, do nothing4",
|
||||
"type": "n8n-nodes-base.noOp",
|
||||
"typeVersion": 1,
|
||||
"position": [900, 1200]
|
||||
},
|
||||
{
|
||||
"parameters": {},
|
||||
"id": "93745a80-a2b6-414b-bcf0-938f2a2da985",
|
||||
"name": "No Operation, do nothing5",
|
||||
"type": "n8n-nodes-base.noOp",
|
||||
"typeVersion": 1,
|
||||
"position": [900, 1340]
|
||||
}
|
||||
],
|
||||
"pinData": {
|
||||
"No Operation, do nothing5": [
|
||||
{
|
||||
"json": {
|
||||
"data": "2023/05/01"
|
||||
}
|
||||
}
|
||||
],
|
||||
"No Operation, do nothing4": [
|
||||
{
|
||||
"json": {
|
||||
"data": "2023/05/01"
|
||||
}
|
||||
}
|
||||
],
|
||||
"No Operation, do nothing3": [
|
||||
{
|
||||
"json": {
|
||||
"data": "2023/05/01"
|
||||
}
|
||||
}
|
||||
],
|
||||
"No Operation, do nothing2": [
|
||||
{
|
||||
"json": {
|
||||
"data": "2023/05/01"
|
||||
}
|
||||
}
|
||||
],
|
||||
"No Operation, do nothing1": [
|
||||
{
|
||||
"json": {
|
||||
"data": "2023/05/01"
|
||||
}
|
||||
}
|
||||
],
|
||||
"No Operation, do nothing": [
|
||||
{
|
||||
"json": {
|
||||
"data": "2023/05/01"
|
||||
}
|
||||
}
|
||||
]
|
||||
},
|
||||
"connections": {
|
||||
"When clicking \"Execute Workflow\"": {
|
||||
"main": [
|
||||
[
|
||||
{
|
||||
"node": "Set",
|
||||
"type": "main",
|
||||
"index": 0
|
||||
}
|
||||
]
|
||||
]
|
||||
},
|
||||
"Set": {
|
||||
"main": [
|
||||
[
|
||||
{
|
||||
"node": "Date & Time6",
|
||||
"type": "main",
|
||||
"index": 0
|
||||
},
|
||||
{
|
||||
"node": "Date & Time",
|
||||
"type": "main",
|
||||
"index": 0
|
||||
},
|
||||
{
|
||||
"node": "Date & Time1",
|
||||
"type": "main",
|
||||
"index": 0
|
||||
},
|
||||
{
|
||||
"node": "Date & Time2",
|
||||
"type": "main",
|
||||
"index": 0
|
||||
},
|
||||
{
|
||||
"node": "Date & Time3",
|
||||
"type": "main",
|
||||
"index": 0
|
||||
},
|
||||
{
|
||||
"node": "Date & Time4",
|
||||
"type": "main",
|
||||
"index": 0
|
||||
}
|
||||
]
|
||||
]
|
||||
},
|
||||
"Date & Time6": {
|
||||
"main": [
|
||||
[
|
||||
{
|
||||
"node": "No Operation, do nothing",
|
||||
"type": "main",
|
||||
"index": 0
|
||||
}
|
||||
]
|
||||
]
|
||||
},
|
||||
"Date & Time4": {
|
||||
"main": [
|
||||
[
|
||||
{
|
||||
"node": "No Operation, do nothing5",
|
||||
"type": "main",
|
||||
"index": 0
|
||||
}
|
||||
]
|
||||
]
|
||||
},
|
||||
"Date & Time3": {
|
||||
"main": [
|
||||
[
|
||||
{
|
||||
"node": "No Operation, do nothing4",
|
||||
"type": "main",
|
||||
"index": 0
|
||||
}
|
||||
]
|
||||
]
|
||||
},
|
||||
"Date & Time2": {
|
||||
"main": [
|
||||
[
|
||||
{
|
||||
"node": "No Operation, do nothing3",
|
||||
"type": "main",
|
||||
"index": 0
|
||||
}
|
||||
]
|
||||
]
|
||||
},
|
||||
"Date & Time1": {
|
||||
"main": [
|
||||
[
|
||||
{
|
||||
"node": "No Operation, do nothing2",
|
||||
"type": "main",
|
||||
"index": 0
|
||||
}
|
||||
]
|
||||
]
|
||||
},
|
||||
"Date & Time": {
|
||||
"main": [
|
||||
[
|
||||
{
|
||||
"node": "No Operation, do nothing1",
|
||||
"type": "main",
|
||||
"index": 0
|
||||
}
|
||||
]
|
||||
]
|
||||
}
|
||||
},
|
||||
"active": false,
|
||||
"settings": {},
|
||||
"versionId": "19282890-eff2-40ca-be11-a8fff559c964",
|
||||
"id": "21",
|
||||
"meta": {
|
||||
"instanceId": "6ebec4953fe56f1c009e7c3b107578b375137523af057073c0b5da17350651bd"
|
||||
},
|
||||
"tags": []
|
||||
}
|
||||
Reference in New Issue
Block a user