How to use the ng-zorro-antd/core.CandyDate function in ng-zorro-antd

To help you get started, we’ve selected a few ng-zorro-antd examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github NG-ZORRO / ng-zorro-antd / components / date-picker / lib / calendar / calendar-header.component.ts View on Github external
ngOnInit(): void {
    if (!this.value) {
      this.value = new CandyDate(); // Show today by default
    }
    this.render();
  }
github NG-ZORRO / ng-zorro-antd / components / calendar / nz-calendar.spec.ts View on Github external
it('should support two-way binding without model', () => {
      fixture.detectChanges();
      const now = new Date();

      const calendar = fixture.debugElement.queryAll(By.directive(Calendar))[1].injector.get(Calendar);

      expect(calendar.activeDate.nativeDate).toBe(component.date0);

      calendar.onDateSelect(new CandyDate(now));
      fixture.detectChanges();

      expect(component.date0).toBe(now);
    });
github NG-ZORRO / ng-zorro-antd / components / date-picker / lib / popups / date-range-popup.component.ts View on Github external
onClickPresetRange(val: PresetRanges[keyof PresetRanges]): void {
    const value = typeof val === 'function' ? val() : val;
    if (value) {
      this.setValue([new CandyDate(value[0]), new CandyDate(value[1])]);
      this.resultOk.emit();
    }
  }
github NG-ZORRO / ng-zorro-antd / components / date-picker / lib / popups / inner-popup.component.ts View on Github external
onSelectTime(date: Date): void {
    this.selectTime.emit(new CandyDate(date));
  }
github NG-ZORRO / ng-zorro-antd / components / date-picker / abstract-picker.component.ts View on Github external
      this.nzValue = value ? (value as Date[]).map(val => new CandyDate(val)) : [];
    } else {
github NG-ZORRO / ng-zorro-antd / components / calendar / nz-calendar.component.ts View on Github external
@Input() set nzValue(value: Date) {
    this.updateDate(new CandyDate(value), false);
  }
  @Output() readonly nzValueChange: EventEmitter = new EventEmitter();
github NG-ZORRO / ng-zorro-antd / components / calendar / month-table.component.ts View on Github external
private makePanelMonths(): PanelMonthData[][] {
    const months: PanelMonthData[][] = [];
    const currentMonth = this.value.getMonth();
    const today = new CandyDate();

    let monthValue = 0;
    for (let rowIndex = 0; rowIndex < MAX_ROW; rowIndex++) {
      months[rowIndex] = [];
      for (let colIndex = 0; colIndex < MAX_COL; colIndex++) {
        const month = this.value.setMonth(monthValue);
        const disabled = this.disabledDate ? this.disabledDate(this.value.setMonth(monthValue).nativeDate) : false;
        const content = this.dateHelper.format(month.nativeDate, 'MMM');

        const cell: PanelMonthData = (months[rowIndex][colIndex] = {
          value: month.nativeDate,
          disabled,
          content,
          month: monthValue,
          title: content,
          classMap: null,
github NG-ZORRO / ng-zorro-antd / components / calendar / nz-calendar.component.ts View on Github external
writeValue(value: Date | null): void {
    this.updateDate(new CandyDate(value as Date), false);
    this.cdr.markForCheck();
  }
github NG-ZORRO / ng-zorro-antd / components / date-picker / lib / popups / date-range-popup.component.ts View on Github external
private normalizeRangeValue(value: CandyDate[]): CandyDate[] {
    const [start, end] = value;
    const newStart = start || new CandyDate();
    const newEnd = end && end.isSameMonth(newStart) ? end.addMonths(1) : end || newStart.addMonths(1);
    return [newStart, newEnd];
  }