n8n-nodes-base
Version:
Base nodes of n8n
129 lines (124 loc) • 4.39 kB
text/typescript
/**
* Date & Time Node - Version 2
* Manipulate date and time values
*/
export interface DateTimeV2Params {
operation?: 'addToDate' | 'extractDate' | 'formatDate' | 'getCurrentDate' | 'getTimeBetweenDates' | 'roundDate' | 'subtractFromDate';
/**
* When deactivated, the time will be set to midnight
* @displayOptions.show { operation: ["getCurrentDate"] }
* @default true
*/
includeTime?: boolean | Expression<boolean>;
/**
* Name of the field to put the output in
* @displayOptions.show { operation: ["getCurrentDate"] }
* @default currentDate
*/
outputFieldName?: string | Expression<string> | PlaceholderValue;
/**
* Options
* @displayOptions.show { operation: ["getCurrentDate"] }
* @default {}
*/
options?: {
/** Whether to include all fields of the input item in the output item
* @default false
*/
includeInputFields?: boolean | Expression<boolean>;
/** The timezone to use. If not set, the timezone of the n8n instance will be used. Use ‘GMT’ for +00:00 timezone.
*/
timezone?: string | Expression<string> | PlaceholderValue;
/** 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.
* @hint Tokens are case sensitive
* @default e.g yyyyMMdd
*/
fromFormat?: string | Expression<string> | PlaceholderValue;
/** Whether to output the date as ISO string or not
* @default false
*/
isoString?: boolean | Expression<boolean>;
};
/**
* The date that you want to change
* @displayOptions.show { operation: ["addToDate"] }
*/
magnitude?: string | Expression<string> | PlaceholderValue;
/**
* Time unit for Duration parameter below
* @displayOptions.show { operation: ["addToDate"] }
* @default days
*/
timeUnit?: 'years' | 'quarters' | 'months' | 'weeks' | 'days' | 'hours' | 'minutes' | 'seconds' | 'milliseconds' | Expression<string>;
/**
* The number of time units to add to the date
* @displayOptions.show { operation: ["addToDate"] }
* @default 0
*/
duration?: number | Expression<number>;
/**
* The date that you want to format
* @displayOptions.show { operation: ["formatDate"] }
*/
date?: string | Expression<string> | PlaceholderValue;
/**
* The format to convert the date to
* @displayOptions.show { operation: ["formatDate"] }
* @default MM/dd/yyyy
*/
format?: 'custom' | 'MM/dd/yyyy' | 'yyyy/MM/dd' | 'MMMM dd yyyy' | 'MM-dd-yyyy' | 'yyyy-MM-dd' | 'X' | 'x' | Expression<string>;
/**
* Custom Format
* @hint List of special tokens <a target="_blank" href="https://moment.github.io/luxon/#/formatting?id=table-of-tokens">More info</a>
* @displayOptions.show { format: ["custom"], operation: ["formatDate"] }
*/
customFormat?: string | Expression<string> | PlaceholderValue;
/**
* Mode
* @displayOptions.show { operation: ["roundDate"] }
* @default roundDown
*/
mode?: 'roundDown' | 'roundUp' | Expression<string>;
/**
* To Nearest
* @displayOptions.show { operation: ["roundDate"], mode: ["roundDown"] }
* @default month
*/
toNearest?: 'year' | 'month' | 'week' | 'day' | 'hour' | 'minute' | 'second' | Expression<string>;
/**
* To
* @displayOptions.show { operation: ["roundDate"], mode: ["roundUp"] }
* @default month
*/
to?: 'month' | Expression<string>;
/**
* Start Date
* @displayOptions.show { operation: ["getTimeBetweenDates"] }
*/
startDate?: string | Expression<string> | PlaceholderValue;
/**
* End Date
* @displayOptions.show { operation: ["getTimeBetweenDates"] }
*/
endDate?: string | Expression<string> | PlaceholderValue;
/**
* Units
* @displayOptions.show { operation: ["getTimeBetweenDates"] }
* @default ["day"]
*/
units?: Array<'year' | 'month' | 'week' | 'day' | 'hour' | 'minute' | 'second' | 'millisecond'>;
/**
* Part
* @displayOptions.show { operation: ["extractDate"] }
* @default month
*/
part?: 'year' | 'month' | 'week' | 'day' | 'hour' | 'minute' | 'second' | Expression<string>;
}
interface DateTimeV2NodeBase {
type: 'n8n-nodes-base.dateTime';
version: 2;
}
export type DateTimeV2ParamsNode = DateTimeV2NodeBase & {
config: NodeConfig<DateTimeV2Params>;
};
export type DateTimeV2Node = DateTimeV2ParamsNode;