Fix date parsing if no date was provided
This commit is contained in:
parent
435406dca3
commit
335986cc47
|
@ -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')
|
||||
|
||||
|
|
|
@ -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 {
|
||||
|
|
Reference in New Issue