forked from NG-ZORRO/ng-zorro-antd
-
Notifications
You must be signed in to change notification settings - Fork 0
/
semantic.ts
28 lines (24 loc) · 784 Bytes
/
semantic.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
import { Component } from '@angular/core';
import { parseExpression } from 'cron-parser';
import { NzSafeAny } from 'ng-zorro-antd/core/types';
@Component({
selector: 'nz-demo-cron-expression-semantic',
template: ` <nz-cron-expression
[nzSemantic]="semanticTemplate"
[(ngModel)]="value"
(ngModelChange)="getValue($event)"
></nz-cron-expression>
<ng-template #semanticTemplate>Next Time: {{ semantic | date: 'YYYY-MM-dd HH:mm:ss' }}</ng-template>`
})
export class NzDemoCronExpressionSemanticComponent {
value: string = '10 * * * *';
semantic?: Date;
getValue(value: string): void {
try {
const interval = parseExpression(value);
this.semantic = interval.next().toDate();
} catch (err: NzSafeAny) {
return;
}
}
}