diff --git a/components/date-picker/date-picker.component.ts b/components/date-picker/date-picker.component.ts index 5d2a28479dc..6652f995a32 100644 --- a/components/date-picker/date-picker.component.ts +++ b/components/date-picker/date-picker.component.ts @@ -210,6 +210,7 @@ export type NzPlacement = 'bottomLeft' | 'bottomRight' | 'topLeft' | 'topRight'; [extraFooter]="extraFooter" [ranges]="nzRanges" [dir]="dir" + [format]="nzFormat" (resultOk)="onResultOk()" /> diff --git a/components/date-picker/date-range-popup.component.ts b/components/date-picker/date-range-popup.component.ts index ba654a8972f..17bcec96161 100644 --- a/components/date-picker/date-range-popup.component.ts +++ b/components/date-picker/date-range-popup.component.ts @@ -106,6 +106,7 @@ import { getTimeConfig, isAllowedDate, PREFIX_CLASS } from './util'; [dateRender]="dateRender" [selectedValue]="$any(datePickerService?.value)" [hoverValue]="$any(hoverValue)" + [format]="format" (cellHover)="onCellHover($event)" (selectDate)="changeValueFromSelect($event, !showTime)" (selectTime)="onSelectTime($event, partType)" @@ -164,6 +165,7 @@ export class DateRangePopupComponent implements OnInit, OnChanges, OnDestroy { @Input() panelMode!: NzDateMode | NzDateMode[]; @Input() defaultPickerValue!: CompatibleDate | undefined | null; @Input() dir: Direction = 'ltr'; + @Input() format?: string; @Output() readonly panelModeChange = new EventEmitter(); @Output() readonly calendarChange = new EventEmitter(); diff --git a/components/date-picker/inner-popup.component.ts b/components/date-picker/inner-popup.component.ts index bd665ab3a01..fdacbd24493 100644 --- a/components/date-picker/inner-popup.component.ts +++ b/components/date-picker/inner-popup.component.ts @@ -154,6 +154,7 @@ import { PREFIX_CLASS } from './util'; [selectedValue]="selectedValue" [hoverValue]="hoverValue" [canSelectWeek]="panelMode === 'week'" + [format]="format" (valueChange)="onSelectDate($event)" (cellHover)="cellHover.emit($event)" /> @@ -198,6 +199,7 @@ export class InnerPopupComponent implements OnChanges { @Input() hoverValue!: CandyDate[]; // Range ONLY @Input() value!: CandyDate; @Input() partType!: RangePartType; + @Input() format?: string; @Output() readonly panelChange = new EventEmitter(); // TODO: name is not proper diff --git a/components/date-picker/lib/date-table.component.ts b/components/date-picker/lib/date-table.component.ts index 1ea7aa1a349..0ce9f72d71d 100644 --- a/components/date-picker/lib/date-table.component.ts +++ b/components/date-picker/lib/date-table.component.ts @@ -26,6 +26,7 @@ import { transCompatFormat } from './util'; }) export class DateTableComponent extends AbstractTable implements OnChanges, OnInit { @Input() override locale!: NzCalendarI18nInterface; + @Input() format?: string; constructor(private i18n: NzI18nService, private dateHelper: DateHelperService) { super(); @@ -78,7 +79,7 @@ export class DateTableComponent extends AbstractTable implements OnChanges, OnIn for (let day = 0; day < 7; day++) { const date = weekStart.addDays(day); - const dateFormat = transCompatFormat(this.i18n.getLocaleData('DatePicker.lang.dateFormat', 'YYYY-MM-DD')); + const dateFormat = transCompatFormat(this.format ?? this.i18n.getLocaleData('DatePicker.lang.dateFormat', 'YYYY-MM-DD')); const title = this.dateHelper.format(date.nativeDate, dateFormat); const label = this.dateHelper.format(date.nativeDate, 'dd'); const cell: DateCell = {