Skip to content

Commit c6cc553

Browse files
committed
feat: monthly language feature #11
1 parent 824fded commit c6cc553

4 files changed

Lines changed: 5450 additions & 3475 deletions

File tree

index.js

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
const langParser = (pattern, string) => {
22
const matchyear = /yearly/.test(string);
33
const matchweek = /weekly/.test(string);
4+
const matchmonth = /monthly/.test(string);
45
const matchquarter = /quarterly/.test(string);
56
if (matchyear) {
67
return pattern.map((e, idx) => {
@@ -29,6 +30,19 @@ const langParser = (pattern, string) => {
2930
});
3031
}
3132

33+
if (matchmonth) {
34+
pattern[4] = '*/1';
35+
pattern[3] = pattern[5] !== '*' ? '*' : '1';
36+
let changed = false;
37+
return pattern.map((e, idx) => {
38+
if (idx < 3 && e === '*' && !changed) {
39+
return 0;
40+
}
41+
changed = true;
42+
return e;
43+
});
44+
}
45+
3246
if (matchquarter) {
3347
pattern[4] = '*/3';
3448
let changed = false;

0 commit comments

Comments
 (0)