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 year': {type: 'years', amount: 1},
|
||||||
'every 1 year': {type: 'years', amount: 1},
|
'every 1 year': {type: 'years', amount: 1},
|
||||||
'every 4 years': {type: 'years', amount: 4},
|
'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) {
|
for (const c in cases) {
|
||||||
|
|
|
@ -157,7 +157,7 @@ const getPriority = (text: string, prefix: string): number | null => {
|
||||||
}
|
}
|
||||||
|
|
||||||
const getRepeats = (text: string): repeatParsedResult => {
|
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)
|
const results = regex.exec(text)
|
||||||
if (results === null) {
|
if (results === null) {
|
||||||
return {
|
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
|
let type: RepeatType = RepeatType.Hours
|
||||||
|
|
||||||
switch (results[4]) {
|
switch (results[0]) {
|
||||||
case 'hour':
|
case 'biennially':
|
||||||
case 'hours':
|
type = RepeatType.Years
|
||||||
type = RepeatType.Hours
|
amount = 2
|
||||||
break
|
break
|
||||||
case 'day':
|
case 'bianually':
|
||||||
case 'days':
|
case 'semiannually':
|
||||||
type = RepeatType.Days
|
|
||||||
break
|
|
||||||
case 'week':
|
|
||||||
case 'weeks':
|
|
||||||
type = RepeatType.Weeks
|
|
||||||
break
|
|
||||||
case 'month':
|
|
||||||
case 'months':
|
|
||||||
type = RepeatType.Months
|
type = RepeatType.Months
|
||||||
|
amount = 6
|
||||||
break
|
break
|
||||||
case 'year':
|
case 'yearly':
|
||||||
case 'years':
|
case 'anually':
|
||||||
type = RepeatType.Years
|
type = RepeatType.Years
|
||||||
break
|
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 {
|
return {
|
||||||
|
|
Reference in New Issue