n8n/packages/nodes-base/nodes/DateTime/V2/GetTimeBetweenDates.ts
agobrech 7d1d1f7872
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 46b59bea2e.

* 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

*  restored removed test case, sync v1 with curent master

*  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 17:34:14 +02:00

106 lines
1.8 KiB
TypeScript

import type { INodeProperties } from 'n8n-workflow';
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: [
{
displayName: 'Output as ISO String',
name: 'isoString',
type: 'boolean',
default: false,
description: 'Whether to output the date as ISO string or not',
},
],
},
];