Writing a custom date adapter

If neither of the provided date adapters is suitable for your project, it is possible to create your own date-time implementation. Making the picker work with a different date & time implementation is as easy as extending DateTimeAdapter. You will also want to provide a matching NXT_DATE_TIME_FORMATS to configure formatting strings for your implementation.

Custom date & time adapter module

View on GitHub
import { Injectable, NgModule } from '@angular/core'
import { CustomDateModel } from 'custom-date-library'
import { DateTimeAdapter, DateTimeFormats, NXT_DATE_TIME_FORMATS } from 'nxt-pick-datetime'
// Provide formatting strings for your date adapter implementation
export const CUSTOM_DATE_TIME_FORMATS: DateTimeFormats = {
parseInput: 'formatting string for your implementation',
fullPickerInput: 'formatting string for your implementation',
datePickerInput: 'formatting string for your implementation',
timePickerInput: 'formatting string for your implementation',
monthYearLabel: 'formatting string for your implementation',
dateA11yLabel: 'formatting string for your implementation',
monthYearA11yLabel: 'formatting string for your implementation'
}
@Injectable()
export class CustomDateTimeAdapter extends DateTimeAdapter<CustomDateModel> {
// Implement DateTimeAdapter here
}
@NgModule({
providers: [
{
provide: DateTimeAdapter,
useClass: CustomDateTimeAdapter
},
{
provide: NXT_DATE_TIME_FORMATS,
useValue: CUSTOM_DATE_TIME_FORMATS
}
]
})
export class CustomDateTimeModule { }