feat: add support for more cases
continuous-integration/drone/pr Build is failing
Details
continuous-integration/drone/pr Build is failing
Details
This commit is contained in:
parent
903d02be61
commit
fbeeff6e59
|
@ -529,6 +529,15 @@ describe('Parse Task Text', () => {
|
|||
'every year': {type: 'years', amount: 1},
|
||||
'every 1 year': {type: 'years', amount: 1},
|
||||
'every 4 years': {type: 'years', amount: 4},
|
||||
'anually': {type: 'years', amount: 1},
|
||||
'bianually': {type: 'months', amount: 6},
|
||||
'semiannually': {type: 'months', amount: 6},
|
||||
'biennially': {type: 'years', amount: 2},
|
||||
'daily': {type: 'days', amount: 1},
|
||||
'hourly': {type: 'hours', amount: 1},
|
||||
'monthly': {type: 'months', amount: 1},
|
||||
'weekly': {type: 'weeks', amount: 1},
|
||||
'yearly': {type: 'years', amount: 1},
|
||||
}
|
||||
|
||||
for (const c in cases) {
|
||||
|
|
|
@ -157,7 +157,7 @@ const getPriority = (text: string, prefix: string): number | null => {
|
|||
}
|
||||
|
||||
const getRepeats = (text: string): repeatParsedResult => {
|
||||
const regex = /((every|each) ([0-9]+ )?(hours?|days?|weeks?|months?|years?))/ig
|
||||
const regex = /((every|each) ([0-9]+ )?(hours?|days?|weeks?|months?|years?))|anually|bianually|semiannually|biennially|daily|hourly|monthly|weekly|yearly/ig
|
||||
const results = regex.exec(text)
|
||||
if (results === null) {
|
||||
return {
|
||||
|
@ -166,30 +166,58 @@ const getRepeats = (text: string): repeatParsedResult => {
|
|||
}
|
||||
}
|
||||
|
||||
const amount = results[3] ? parseInt(results[3]) : 1
|
||||
let amount = results[3] ? parseInt(results[3]) : 1
|
||||
let type: RepeatType = RepeatType.Hours
|
||||
|
||||
switch (results[4]) {
|
||||
case 'hour':
|
||||
case 'hours':
|
||||
type = RepeatType.Hours
|
||||
switch (results[0]) {
|
||||
case 'biennially':
|
||||
type = RepeatType.Years
|
||||
amount = 2
|
||||
break
|
||||
case 'day':
|
||||
case 'days':
|
||||
type = RepeatType.Days
|
||||
break
|
||||
case 'week':
|
||||
case 'weeks':
|
||||
type = RepeatType.Weeks
|
||||
break
|
||||
case 'month':
|
||||
case 'months':
|
||||
case 'bianually':
|
||||
case 'semiannually':
|
||||
type = RepeatType.Months
|
||||
amount = 6
|
||||
break
|
||||
case 'year':
|
||||
case 'years':
|
||||
case 'yearly':
|
||||
case 'anually':
|
||||
type = RepeatType.Years
|
||||
break
|
||||
case 'daily':
|
||||
type = RepeatType.Days
|
||||
break
|
||||
case 'hourly':
|
||||
type = RepeatType.Hours
|
||||
break
|
||||
case 'monthly':
|
||||
type = RepeatType.Months
|
||||
break
|
||||
case 'weekly':
|
||||
type = RepeatType.Weeks
|
||||
break
|
||||
default:
|
||||
switch (results[4]) {
|
||||
case 'hour':
|
||||
case 'hours':
|
||||
type = RepeatType.Hours
|
||||
break
|
||||
case 'day':
|
||||
case 'days':
|
||||
type = RepeatType.Days
|
||||
break
|
||||
case 'week':
|
||||
case 'weeks':
|
||||
type = RepeatType.Weeks
|
||||
break
|
||||
case 'month':
|
||||
case 'months':
|
||||
type = RepeatType.Months
|
||||
break
|
||||
case 'year':
|
||||
case 'years':
|
||||
type = RepeatType.Years
|
||||
break
|
||||
}
|
||||
}
|
||||
|
||||
return {
|
||||
|
|
Reference in New Issue