|
@@ -2615,7 +2615,7 @@ const configSchema = {
|
|
|
secondField: {
|
|
secondField: {
|
|
|
type: 'string',
|
|
type: 'string',
|
|
|
title: 'Second Date Field',
|
|
title: 'Second Date Field',
|
|
|
- description: 'Path to the date to compare against, for the diff operation'
|
|
|
|
|
|
|
+ description: 'Path to the date to compare against, for the diff operation. diff returns the input date minus this one, so a later input gives a positive result'
|
|
|
},
|
|
},
|
|
|
format: {
|
|
format: {
|
|
|
type: 'string',
|
|
type: 'string',
|
|
@@ -2696,7 +2696,13 @@ function offsetMinutes(offset) {
|
|
|
if (!match) {
|
|
if (!match) {
|
|
|
throw new Error('Date and Time: offset must look like +02:00, got "' + offset + '"');
|
|
throw new Error('Date and Time: offset must look like +02:00, got "' + offset + '"');
|
|
|
}
|
|
}
|
|
|
- const minutes = parseInt(match[2], 10) * 60 + parseInt(match[3], 10);
|
|
|
|
|
|
|
+ const hours = parseInt(match[2], 10);
|
|
|
|
|
+ const mins = parseInt(match[3], 10);
|
|
|
|
|
+ if (hours > 14 || mins > 59) {
|
|
|
|
|
+ throw new Error('Date and Time: offset "' + offset +
|
|
|
|
|
+ '" is out of range. Real offsets run from -12:00 to +14:00');
|
|
|
|
|
+ }
|
|
|
|
|
+ const minutes = hours * 60 + mins;
|
|
|
return match[1] === '-' ? -minutes : minutes;
|
|
return match[1] === '-' ? -minutes : minutes;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
@@ -2775,7 +2781,11 @@ async function execute(config, input, context) {
|
|
|
return result;
|
|
return result;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- const delta = (Number(config.amount) || 0) * step;
|
|
|
|
|
|
|
+ const amount = Number(config.amount);
|
|
|
|
|
+ if (isNaN(amount)) {
|
|
|
|
|
+ throw new Error('Date and Time: amount must be a number, got "' + config.amount + '"');
|
|
|
|
|
+ }
|
|
|
|
|
+ const delta = amount * step;
|
|
|
const shifted = operation === 'subtract' ? timestamp - delta : timestamp + delta;
|
|
const shifted = operation === 'subtract' ? timestamp - delta : timestamp + delta;
|
|
|
result[outputField] = formatTimestamp(shifted, pattern, offset);
|
|
result[outputField] = formatTimestamp(shifted, pattern, offset);
|
|
|
result.timestamp = shifted;
|
|
result.timestamp = shifted;
|