import { Inject , Injectable , LOCALE_ID , Optional } from '@angular/core' ; import { SBB_DATEPICKER_2DIGIT_YEAR_PIVOT } from './datepicker-token' ; import { SbbNativeDateAdapter } from './native-date-adapter' ; @ Injectable ( ) export class SbbLeanDateAdapter extends SbbNativeDateAdapter { constructor ( @ Inject ( LOCALE_ID ) protected override _locale , @ Optional ( ) @ Inject ( SBB_DATEPICKER_2DIGIT_YEAR_PIVOT ) yearPivot ) { super ( _locale , yearPivot ) ; } protected override _parseStringDate ( value ) { return super . _parseStringDate ( value ) || this . _parseStringDateLean ( value ) ; } private _parseStringDateLean ( value ) { const match = /^(\w+,[ ]?)?(\d{2})(\d{2})(\d{2}|\d{4})$/ . exec ( value ) ; if ( ! match ) { return null ; } return this . _normalizeYear ( this . _createDateWithOverflow ( + match [ 4 ] , + match [ 3 ] - 1 , + match [ 2 ] ) ) ; } }