Skip to content

[DatePicker] DateTableComponent generates incorrect calendar grid with custom DateAdapter in v22 #9885

Description

@saeidi-dev

Reproduction link

https://stackblitz.com/edit/ng-zorro-antd

Description

When using a custom NzDateAdapter implementation for a non-Gregorian calendar (such as Jalali calendar), the month table generated by DateTableComponent is not correctly calculated based on the provided adapter.

The calendar view appears to mix native Date (Gregorian) calculations with the custom calendar implementation. As a result, the generated days grid (including previous/next month days and the current month days) does not match the expected Jalali calendar structure.

After debugging DateTableComponent, I noticed that the month grid generation is mainly performed through CandyDate operations:

  • calendarStart()
  • addDays()
  • isToday()
  • isSameDay()
  • isSameMonth()

Since these operations are responsible for generating the calendar cells and determining the "Today" state, I suspect that some calendar calculations may not fully respect the configured NzDateAdapter.

With a custom Jalali DateAdapter, the displayed month grid and the highlighted "Today" cell do not match the expected Jalali calendar behavior.

Could you please confirm whether CandyDate is expected to be adapter-aware for custom calendar implementations?

Steps to reproduce

  1. Create an Angular application with NG-ZORRO v22.
  2. Provide a custom NzDateAdapter for Jalali calendar support.
  3. Render an nz-date-picker.
  4. Open the date picker panel.
  5. Navigate between months and inspect the generated day table.
  6. Compare the displayed grid with the expected Jalali calendar.

What is expected?

DateTableComponent should build the month grid entirely using the configured NzDateAdapter.

All calculations related to:

  • first day of month
  • number of days in month
  • previous/next month overflow days
  • day of week calculation

should respect the custom calendar implementation.

What is actually happening?

The generated date table does not match the custom calendar.

The month grid seems to be calculated using native Gregorian Date behavior in some parts instead of delegating all calendar calculations to NzDateAdapter.

This causes incorrect day positions and incorrect "Today" highlighting when using a Jalali DateAdapter.

DateTableComponent --->CandyDate ---> native Date


DateTableComponent ---> NzDateAdapter ---> Jalali calendar

Environment Info
ng-zorro-antd 22.0.0
Browser chrome

@Laffery

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions