-
Notifications
You must be signed in to change notification settings - Fork 60
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Increased date time adapter compatibility #193
base: master
Are you sure you want to change the base?
Increased date time adapter compatibility #193
Conversation
Added two public variables to DateTimeAdapter class to increase compatibility
Added two protected variables to NativeDateTimeAdapter class to match the base DateTimeAdapter class interface
Added two protected variables to UnixTimestampDateTimeAdapter class to match the base DateTimeAdapter class interface
Modified generateWeekDays method to include DateTimeAdapter firstDayOfTheWeek variable
Modified selectYear, createYearCell, & isYearEnabled methods to replace hard-coded first month integer with DateTimeAdapter firstMonthOfTheYear variable
Modified generateMonthList & createMonthCell methods to include DateTimeAdapter firstMonthOfTheYear variable
thank you @Venators , left a comment |
@@ -26,6 +26,9 @@ const ISO_8601_REGEX = /^\d{4}-\d{2}-\d{2}(?:T\d{2}:\d{2}:\d{2}(?:\.\d+)?(?:Z|(? | |||
|
|||
@Injectable() | |||
export class NativeDateTimeAdapter extends DateTimeAdapter<Date> { | |||
protected firstMonthOfTheYear: number = 0; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@Venators for all the time adapters, you've incorrectly extended the base class, causing a build error for production.
DateTimeAdapter
has firstMonthOfTheYear
and firstDayOfTheWeek
public, but the derived adapters are changing the access modifiers to something more strict (protected).
Thanks to the date-time picker's date implementation agnostic nature, it's easy for developers to work with their preferred date implementations. Out of the gate, they are treated to four pre-made modules: Native, Unix Timestamp, DayJs, and Moment.
However, all four of those date implementations use 0-indexed day of the week and month arrays, and subsequently, the date-time picker has hard-coded variables and 0-based logic that makes the library partially incompatible with date implementations that use different indexing, like Luxon, regardless of the custom date-time adapter in use.
The minor changes in this PR retain the current behaviour and compatibility with the current 0-indexed date implementations whilst also increasing the library's compatibility with 1-indexed date implementations.