n8n/packages/nodes-base/nodes/DateTime/V2/FormatDateDescription.ts

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

132 lines
2.8 KiB
TypeScript
Raw Normal View History

feat(Date & Time Node): Overhaul of the node (#5904) * Setup versionized node * Fix node naming * Set all possible actions * Add Current Date operation * Add timezone to current date * feat add to date operator * Change output field name to camel case * Fix info box for luxons tip * Feat subtract to date operation * Feat format date operation * Fix to node field for format date * Feat rounding operation * Feat get in between date operation * Feat add extract date operation * Add generic function for parsing date * Remove moment methods from operations * Change moment to luxon for the rest of the operations * Fix Format date operation * Fix format value * Add timezone option for current date * Add tests, improve workflow settings for testing, toString the results * Change icon for V2 * Revert "Change icon for V2" This reverts commit 46b59bea2ec6dd02a22f8d07a9736b42d751d10f. * Change workflow test name * Fix ui bug for custom format * Fix default value for format operation * Fix info box for rounding operation * Change default for units for between time operation * Inprove fields and resort time units * Fix extract week number * Resolve issue with formating and timezones * Fix field name and unit order * :zap: restored removed test case, sync v1 with curent master * :zap: parseDate update to support timestamps, tests * Keep same field for substract and add time * Update unit test * Improve visibility, add iso to string option * Update option naming --------- Co-authored-by: Michael Kret <michael.k@radency.com>
2023-05-08 08:34:14 -07:00
import type { INodeProperties } from 'n8n-workflow';
import { includeInputFields } from './common.descriptions';
feat(Date & Time Node): Overhaul of the node (#5904) * Setup versionized node * Fix node naming * Set all possible actions * Add Current Date operation * Add timezone to current date * feat add to date operator * Change output field name to camel case * Fix info box for luxons tip * Feat subtract to date operation * Feat format date operation * Fix to node field for format date * Feat rounding operation * Feat get in between date operation * Feat add extract date operation * Add generic function for parsing date * Remove moment methods from operations * Change moment to luxon for the rest of the operations * Fix Format date operation * Fix format value * Add timezone option for current date * Add tests, improve workflow settings for testing, toString the results * Change icon for V2 * Revert "Change icon for V2" This reverts commit 46b59bea2ec6dd02a22f8d07a9736b42d751d10f. * Change workflow test name * Fix ui bug for custom format * Fix default value for format operation * Fix info box for rounding operation * Change default for units for between time operation * Inprove fields and resort time units * Fix extract week number * Resolve issue with formating and timezones * Fix field name and unit order * :zap: restored removed test case, sync v1 with curent master * :zap: parseDate update to support timestamps, tests * Keep same field for substract and add time * Update unit test * Improve visibility, add iso to string option * Update option naming --------- Co-authored-by: Michael Kret <michael.k@radency.com>
2023-05-08 08:34:14 -07:00
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-examples/expressions/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,
feat(Date & Time Node): Overhaul of the node (#5904) * Setup versionized node * Fix node naming * Set all possible actions * Add Current Date operation * Add timezone to current date * feat add to date operator * Change output field name to camel case * Fix info box for luxons tip * Feat subtract to date operation * Feat format date operation * Fix to node field for format date * Feat rounding operation * Feat get in between date operation * Feat add extract date operation * Add generic function for parsing date * Remove moment methods from operations * Change moment to luxon for the rest of the operations * Fix Format date operation * Fix format value * Add timezone option for current date * Add tests, improve workflow settings for testing, toString the results * Change icon for V2 * Revert "Change icon for V2" This reverts commit 46b59bea2ec6dd02a22f8d07a9736b42d751d10f. * Change workflow test name * Fix ui bug for custom format * Fix default value for format operation * Fix info box for rounding operation * Change default for units for between time operation * Inprove fields and resort time units * Fix extract week number * Resolve issue with formating and timezones * Fix field name and unit order * :zap: restored removed test case, sync v1 with curent master * :zap: parseDate update to support timestamps, tests * Keep same field for substract and add time * Update unit test * Improve visibility, add iso to string option * Update option naming --------- Co-authored-by: Michael Kret <michael.k@radency.com>
2023-05-08 08:34:14 -07:00
{
displayName: 'Use Workflow Timezone',
name: 'timezone',
type: 'boolean',
default: false,
description: "Whether to use the timezone of the input or the workflow's timezone",
},
],
},
];