Skip to content
This repository has been archived by the owner on Sep 21, 2024. It is now read-only.

Commit

Permalink
Merge pull request #14 from bogdanmarin/master
Browse files Browse the repository at this point in the history
make default advanced cron valid when seconds or years are removed
  • Loading branch information
claudiuconstantin authored Mar 6, 2019
2 parents 642746d + cfe8f1c commit c2d3ca0
Showing 1 changed file with 17 additions and 1 deletion.
18 changes: 17 additions & 1 deletion projects/cron-editor/src/lib/cron-editor.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -372,6 +372,22 @@ export class CronEditorComponent implements OnInit, OnChanges {
return;
}

private getDefaultAdvancedCronExpression(): string {
if (this.options.removeSeconds && !this.options.removeYears) {
return '15 10 L-2 * ? 2019';
}

if (!this.options.removeSeconds && this.options.removeYears) {
return '0 15 10 L-2 * ?';
}

if (this.options.removeSeconds && this.options.removeYears) {
return '15 10 L-2 * ?';
}

return '0 15 10 L-2 * ? 2019';
}

private getDefaultState() {
const [defaultHours, defaultMinutes, defaultSeconds] = this.options.defaultTime.split(':').map(Number);

Expand Down Expand Up @@ -455,7 +471,7 @@ export class CronEditorComponent implements OnInit, OnChanges {
}
},
advanced: {
expression: '0 15 10 L-2 * ?'
expression: this.getDefaultAdvancedCronExpression()
},
validation: {
isValid: true,
Expand Down

0 comments on commit c2d3ca0

Please sign in to comment.