Skip to content

Commit

Permalink
fix(plugins/dates): match ^in
Browse files Browse the repository at this point in the history
  • Loading branch information
Fdawgs committed Aug 12, 2024
1 parent 2178719 commit fd45122
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 6 deletions.
6 changes: 3 additions & 3 deletions plugins/dates/src/api/parse/range/02-date-range.js
Original file line number Diff line number Diff line change
Expand Up @@ -141,9 +141,9 @@ export default [
},

{
// 2 to 4 weeks
match: '[<min>#Value] to [<max>#Value] [<unit>(day|days|week|weeks|month|months|year|years)]',
desc: '2 to 4 weeks',
// in 2 to 4 weeks
match: '^in [<min>#Value] to [<max>#Value] [<unit>(day|days|week|weeks|month|months|year|years)]',
desc: 'in 2 to 4 weeks',
parse: (m, context) => {
const { min, max, unit } = m.groups()

Expand Down
8 changes: 5 additions & 3 deletions plugins/dates/tests/duration-range.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,12 +25,14 @@ const context = {
today: '2024-01-01',
}

test('duration-ranges', function (t) {
test('future duration-ranges', function (t) {
durArr.forEach(obj => {
obj.text.forEach(text => {
const doc = nlp(text)
const duration = doc.dates(context).get()[0].duration
const doc = nlp(`in ${text}`)
const { duration, start, end } = doc.dates(context).get()[0]
t.deepEqual(duration, obj.duration, text)
t.ok(start > context.today, 'start date')
t.ok(end > start, 'end date')
})
})
t.end()
Expand Down

0 comments on commit fd45122

Please sign in to comment.