diff --git a/src/cdk/v2/destinations/clicksend/utils.js b/src/cdk/v2/destinations/clicksend/utils.js index 3b28f752fd5..797ea12025e 100644 --- a/src/cdk/v2/destinations/clicksend/utils.js +++ b/src/cdk/v2/destinations/clicksend/utils.js @@ -41,9 +41,9 @@ const deduceSchedule = (eventLevelSchedule, timestamp, destConfig) => { } if (defaultCampaignScheduleUnit === 'day') { - date.setDate(date.getDate() + defaultCampaignScheduleInt); + date.setUTCDate(date.getUTCDate() + defaultCampaignScheduleInt); } else if (defaultCampaignScheduleUnit === 'minute') { - date.setMinutes(date.getMinutes() + defaultCampaignScheduleInt); + date.setUTCMinutes(date.getUTCMinutes() + defaultCampaignScheduleInt); } else { throw new Error("Invalid delta unit. Use 'day' or 'minute'."); } diff --git a/src/cdk/v2/destinations/clicksend/utils.test.js b/src/cdk/v2/destinations/clicksend/utils.test.js index 37e371354d7..ef4468b6fe7 100644 --- a/src/cdk/v2/destinations/clicksend/utils.test.js +++ b/src/cdk/v2/destinations/clicksend/utils.test.js @@ -101,6 +101,20 @@ describe('deduceSchedule', () => { expect(result).toBe(expectedTimestamp); }); + it('should calculate timestamp when defaultCampaignSchedule has trailing invalid text and/or leading space', () => { + const eventLevelSchedule = null; + const timestamp = '2023-10-01T00:00:00Z'; + const destConfig = { + defaultCampaignScheduleUnit: 'minute', + defaultCampaignSchedule: ' 5Invalid.String ', + }; + + const result = deduceSchedule(eventLevelSchedule, timestamp, destConfig); + const expectedTimestamp = new Date('2023-10-01T00:05:00Z').getTime() / 1000; + + expect(result).toBe(expectedTimestamp); + }); + // returns UNIX timestamp in seconds it('should return UNIX timestamp in seconds', () => { const eventLevelSchedule = null;