diff --git a/src/Scripting/Postponer.ts b/src/Scripting/Postponer.ts index 9f9cd9b2dc..3990842c42 100644 --- a/src/Scripting/Postponer.ts +++ b/src/Scripting/Postponer.ts @@ -58,13 +58,16 @@ export function postponeButtonTitle(task: Task, amount: number, timeUnit: unitOf } export function postponeMenuItemTitle(task: Task, amount: number, timeUnit: unitOfTime.DurationConstructor) { + function capitalizeFirstLetter(word: string) { + return word.charAt(0).toUpperCase() + word.slice(1); + } const updatedDateType = getDateFieldToPostpone(task)!; const dateToUpdate = task[updatedDateType] as Moment; - const updatedDateDisplayText = updatedDateType.replace('Date', ''); + const updatedDateDisplayText = capitalizeFirstLetter(updatedDateType.replace('Date', '')); const postponedDate = new TasksDate(dateToUpdate).postpone(timeUnit, amount); const formattedNewDate = postponedDate.format('ddd Do MMM, YYYY'); const amountOrArticle = amount > 1 ? amount : 'a'; - return `Postpone ${updatedDateDisplayText} for ${amountOrArticle} ${timeUnit} - to ${formattedNewDate}`; + return `${updatedDateDisplayText} in ${amountOrArticle} ${timeUnit}, on ${formattedNewDate}`; } diff --git a/tests/Scripting/Postponer.test.ts b/tests/Scripting/Postponer.test.ts index bf45c4ab8c..d27d656cb6 100644 --- a/tests/Scripting/Postponer.test.ts +++ b/tests/Scripting/Postponer.test.ts @@ -162,17 +162,17 @@ describe('postpone - UI text', () => { it('should include date type and new date in button tooltip', () => { const task = new TaskBuilder().dueDate(today).build(); expect(postponeButtonTitle(task, 1, 'day')).toEqual( - 'ℹ️ Postpone due for a day - to Mon 4th Dec, 2023 (right-click for more options)', + 'ℹ️ Due in a day, on Mon 4th Dec, 2023 (right-click for more options)', ); expect(postponeButtonTitle(task, 2, 'days')).toEqual( - 'ℹ️ Postpone due for 2 days - to Tue 5th Dec, 2023 (right-click for more options)', + 'ℹ️ Due in 2 days, on Tue 5th Dec, 2023 (right-click for more options)', ); }); it('should include date type and new date in context menu labels', () => { const task = new TaskBuilder().dueDate(today).build(); - expect(postponeMenuItemTitle(task, 1, 'day')).toEqual('Postpone due for a day - to Mon 4th Dec, 2023'); - expect(postponeMenuItemTitle(task, 2, 'days')).toEqual('Postpone due for 2 days - to Tue 5th Dec, 2023'); + expect(postponeMenuItemTitle(task, 1, 'day')).toEqual('Due in a day, on Mon 4th Dec, 2023'); + expect(postponeMenuItemTitle(task, 2, 'days')).toEqual('Due in 2 days, on Tue 5th Dec, 2023'); }); });