1
0

fix(quick add magic): assume today when no date was specified with time

This commit is contained in:
kolaente
2024-06-06 21:44:29 +02:00
parent 5af8b54618
commit 92cdf5fe9c
3 changed files with 24 additions and 2 deletions

View File

@ -79,6 +79,12 @@ export const parseDate = (text: string, now: Date = new Date()): dateParseResult
parsed = getDateFromText(text, now)
if (parsed.date === null) {
const time = addTimeToDate(text, new Date(now), parsed.foundText)
if (time.date !== null && +now !== +time.date) {
return time
}
return {
newText: replaceAll(text, parsed.foundText, ''),
date: parsed.date,
@ -122,7 +128,7 @@ const addTimeToDate = (text: string, date: Date, previousMatch: string | null):
const replace = results !== null ? results[0] : previousMatch
return {
newText: replaceAll(text, replace, '').trim(),
date: date,
date,
}
}