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
- Create an Angular application with NG-ZORRO v22.
- Provide a custom
NzDateAdapter for Jalali calendar support.
- Render an
nz-date-picker.
- Open the date picker panel.
- Navigate between months and inspect the generated day table.
- 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
Reproduction link
https://stackblitz.com/edit/ng-zorro-antd
Description
When using a custom
NzDateAdapterimplementation for a non-Gregorian calendar (such as Jalali calendar), the month table generated byDateTableComponentis 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 throughCandyDateoperations: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
CandyDateis expected to be adapter-aware for custom calendar implementations?Steps to reproduce
NzDateAdapterfor Jalali calendar support.nz-date-picker.What is expected?
DateTableComponentshould build the month grid entirely using the configuredNzDateAdapter.All calculations related to:
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
Datebehavior in some parts instead of delegating all calendar calculations toNzDateAdapter.This causes incorrect day positions and incorrect "Today" highlighting when using a Jalali DateAdapter.
DateTableComponent --->CandyDate ---> native Date
DateTableComponent ---> NzDateAdapter ---> Jalali calendar
@Laffery