Fix date parsing if no date was provided

This commit is contained in:
kolaente 2021-06-28 22:54:57 +02:00
parent 435406dca3
commit 335986cc47
Signed by: konrad
GPG Key ID: F40E70337AB24C9B
2 changed files with 13 additions and 0 deletions

View File

@ -9,6 +9,12 @@ describe('Parse Task Text', () => {
})
describe('Date Parsing', () => {
it('should not return any date if none was provided', () => {
const result = parseTaskText('Lorem Ipsum')
expect(result.text).toBe('Lorem Ipsum')
expect(result.date).toBeNull()
})
it('should ignore casing', () => {
const result = parseTaskText('Lorem Ipsum ToDay')

View File

@ -134,6 +134,13 @@ export const getDateFromText = (text, now = new Date()) => {
}
}
if (result === null) {
return {
foundText,
date: null,
}
}
const date = new Date(result)
if (isNaN(date)) {
return {