File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -48,6 +48,7 @@ const dayParser = (pattern, string) => {
4848} ;
4949
5050const dateParser = ( pattern , string ) => {
51+ const from = / f r o m \s ( [ 0 - 9 ] { 1 , 2 } ) \s t h r o u g h \s ( [ 0 - 9 ] { 1 , 2 } ) / . exec ( string ) ;
5152 const full =
5253 / ( j a n | f e b | m a r | a p r | m a y | j u n | j u l | a u g | s e p | o c t | n o v | d e c ) ( [ 0 - 9 ] { 1 , 2 } ) / . exec (
5354 string
@@ -83,6 +84,11 @@ const dateParser = (pattern, string) => {
8384 }
8485 }
8586
87+ if ( ! full && from ) {
88+ pattern [ 3 ] = `${ from [ 1 ] } -${ from [ 2 ] } ` ;
89+ pattern [ 5 ] = '*' ;
90+ }
91+
8692 return pattern ;
8793} ;
8894
Original file line number Diff line number Diff line change @@ -9,7 +9,7 @@ const test = (check, should) => {
99 if ( expr !== null ) {
1010 const checkexpr = cron . validate ( expr ) ;
1111 if ( ! checkexpr ) {
12- throw new Error ( 'Cron Expression invalid' ) ;
12+ throw new Error ( ` Expression invalid - ${ expr } ` ) ;
1313 }
1414 }
1515 assert . equal ( expr , should ) ;
4545 '0 30 9 * 1,2,3 1,2,6'
4646) ;
4747test ( 'on jan feb every 45 minutes' , '0 */45 * * 1,2 *' ) ;
48+ test (
49+ 'every 15 minutes from 5 through 15 of december and january' ,
50+ '0 */15 * 5-15 1,12 *'
51+ ) ;
52+ //test('every week in 15 minute intervals on january', '0 */15 * */7 1 *');
53+ //test('every week on january', '0 0 0 */7 1 *');
4854
4955if ( process . env . TESTWATCH ) {
5056 process . stdout . write ( '\u001b[3J\u001b[2J\u001b[1J' ) ;
You can’t perform that action at this time.
0 commit comments