Skip to content

Commit 3a1c049

Browse files
authored
fix(date-helper): normlize date expression for the Add/Substract date action (activepieces#10944)
1 parent 42f2da7 commit 3a1c049

2 files changed

Lines changed: 8 additions & 5 deletions

File tree

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
{
22
"name": "@activepieces/piece-date-helper",
3-
"version": "0.1.19"
3+
"version": "0.1.20"
44
}

packages/pieces/community/date-helper/src/lib/actions/add-subtract-date.ts

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -164,8 +164,12 @@ function addSubtractTime(date: Date, expression: string, timeZone?: string): day
164164
let dayjsDate = timeZone ? apDayjs(date).tz(timeZone) : apDayjs(date);
165165

166166
for (let i = 0; i < numbers.length; i++) {
167-
const val = units[i].toLowerCase() as timeParts;
168-
switch (val) {
167+
let val = units[i].toLowerCase();
168+
if (val.endsWith('s')) {
169+
val = val.slice(0, -1);
170+
}
171+
const normalizedVal = val as timeParts;
172+
switch (normalizedVal) {
169173
case timeParts.year:
170174
dayjsDate = dayjsDate.add(numbers[i], 'year');
171175
break;
@@ -189,8 +193,7 @@ function addSubtractTime(date: Date, expression: string, timeZone?: string): day
189193
case timeParts.unix_time:
190194
break;
191195
default: {
192-
const nvr: never = val;
193-
console.error(nvr, 'unhandled case was reached');
196+
console.error(val, 'unhandled case was reached');
194197
}
195198
}
196199
}

0 commit comments

Comments
 (0)