You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Currently, ng-zorro-antd tightly couples its date handling logic with the date-fns library through the CandyDate class. This tight coupling limits the flexibility for developers who need to use alternative date libraries or support different calendar systems, such as the Jalali (Persian) calendar, which is widely used in Iran and other Persian-speaking countries.
In my application, I need to display and manipulate dates using the Jalali calendar. However, due to the current design, integrating Jalali date handling is not feasible without significant modifications to the ng-zorro-antd source code. This limitation hampers the ability to provide a localized and culturally appropriate user experience for end-users who rely on calendars other than the Gregorian calendar.
By introducing a DateAdapter abstraction layer, ng-zorro-antd can allow developers to plug in custom date implementations. This approach is similar to what Angular Material offers and aligns with Angular's flexible and modular design principles. It enables support for various calendar systems and date libraries (e.g., Moment.js, jalali-moment, date-fns-jalali), enhancing the internationalization capabilities of ng-zorro-antd.
Implementing a DateAdapter would solve the problem by decoupling the date handling logic from a specific library, allowing developers to:
Use their preferred date library.
Support different calendar systems required by their application's audience.
Improve the end-user experience by displaying dates in the users' local calendar system.
This feature would make ng-zorro-antd more versatile and applicable to a broader range of applications with diverse internationalization requirements.
What does the proposed API look like?
Introduce a DateAdapter Interface: Define an abstract class or interface specifying all necessary date operations required by ng-zorro-antd components (e.g., addDays, isSameDay, parse).
Implement a Default Adapter Using date-fns: Provide a default implementation of DateAdapter using date-fns, ensuring existing functionality remains unaffected.
Modify CandyDate to Use DateAdapter: Update the CandyDate class to utilize the DateAdapter for all date operations, decoupling it from date-fns.
Allow Custom DateAdapter Implementations: Enable developers to provide custom DateAdapter implementations via Angular's dependency injection, allowing the use of alternative date libraries and calendars (e.g., jalali-moment for the Jalali calendar).
Maintain Backward Compatibility: The default behavior remains unchanged for existing applications, ensuring no breaking changes to the public API.
By introducing the DateAdapter abstraction layer, ng-zorro-antd can enhance its flexibility and internationalization support, allowing developers to meet diverse regional requirements and improve the end-user experience.
The text was updated successfully, but these errors were encountered:
What problem does this feature solve?
Currently, ng-zorro-antd tightly couples its date handling logic with the
date-fns
library through theCandyDate
class. This tight coupling limits the flexibility for developers who need to use alternative date libraries or support different calendar systems, such as the Jalali (Persian) calendar, which is widely used in Iran and other Persian-speaking countries.In my application, I need to display and manipulate dates using the Jalali calendar. However, due to the current design, integrating Jalali date handling is not feasible without significant modifications to the ng-zorro-antd source code. This limitation hampers the ability to provide a localized and culturally appropriate user experience for end-users who rely on calendars other than the Gregorian calendar.
By introducing a
DateAdapter
abstraction layer, ng-zorro-antd can allow developers to plug in custom date implementations. This approach is similar to what Angular Material offers and aligns with Angular's flexible and modular design principles. It enables support for various calendar systems and date libraries (e.g., Moment.js, jalali-moment, date-fns-jalali), enhancing the internationalization capabilities of ng-zorro-antd.Implementing a
DateAdapter
would solve the problem by decoupling the date handling logic from a specific library, allowing developers to:This feature would make ng-zorro-antd more versatile and applicable to a broader range of applications with diverse internationalization requirements.
What does the proposed API look like?
Introduce a
DateAdapter
Interface: Define an abstract class or interface specifying all necessary date operations required by ng-zorro-antd components (e.g.,addDays
,isSameDay
,parse
).Implement a Default Adapter Using
date-fns
: Provide a default implementation ofDateAdapter
usingdate-fns
, ensuring existing functionality remains unaffected.Modify
CandyDate
to UseDateAdapter
: Update theCandyDate
class to utilize theDateAdapter
for all date operations, decoupling it fromdate-fns
.Allow Custom
DateAdapter
Implementations: Enable developers to provide customDateAdapter
implementations via Angular's dependency injection, allowing the use of alternative date libraries and calendars (e.g.,jalali-moment
for the Jalali calendar).Maintain Backward Compatibility: The default behavior remains unchanged for existing applications, ensuring no breaking changes to the public API.
Example Usage with a Custom Adapter:
By introducing the
DateAdapter
abstraction layer, ng-zorro-antd can enhance its flexibility and internationalization support, allowing developers to meet diverse regional requirements and improve the end-user experience.The text was updated successfully, but these errors were encountered: