diff --git a/frontend/src/helpers/time/parseDate.ts b/frontend/src/helpers/time/parseDate.ts index 9d04338bf..b7bad8152 100644 --- a/frontend/src/helpers/time/parseDate.ts +++ b/frontend/src/helpers/time/parseDate.ts @@ -109,7 +109,7 @@ const addTimeToDate = (text: string, date: Date, previousMatch: string | null): } } - const timeRegex = ' (at|@) ([0-9][0-9]?(:[0-9][0-9]?)?( ?(a|p)m)?)' + const timeRegex = ' (at|@) ([0-9][0-9]?(:[0-9][0-9])?( ?(a|p)m)?)' const matcher = new RegExp(timeRegex, 'ig') const results = matcher.exec(text) @@ -118,7 +118,7 @@ const addTimeToDate = (text: string, date: Date, previousMatch: string | null): const parts = time.split(':') let hours = parseInt(parts[0]) let minutes = 0 - if (time.endsWith('pm')) { + if (time.toLowerCase().endsWith('pm')) { hours += 12 } if (parts.length > 1) { @@ -128,6 +128,7 @@ const addTimeToDate = (text: string, date: Date, previousMatch: string | null): date.setHours(hours) date.setMinutes(minutes) date.setSeconds(0) + date.setMilliseconds(0) } const replace = results !== null ? results[0] : previousMatch diff --git a/frontend/src/modules/parseTaskText.test.ts b/frontend/src/modules/parseTaskText.test.ts index d88baf205..0e33ef093 100644 --- a/frontend/src/modules/parseTaskText.test.ts +++ b/frontend/src/modules/parseTaskText.test.ts @@ -96,6 +96,10 @@ describe('Parse Task Text', () => { 'at 3am': '3:0', 'at 3:12 am': '3:12', 'at 3:12 pm': '15:12', + 'at 3:12 AM': '3:12', + 'at 3:12 PM': '15:12', + 'at 3:12 Am': '3:12', + 'at 3:12 Pm': '15:12', } as const for (const c in cases) {