Created
April 9, 2019 14:02
-
-
Save Macadoshis/df72c55c520b802ac2048799c76dc3be to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
export class CmssCalendar extends Calendar { | |
constructor(el: ElementRef, domHandler: DomHandler, renderer: Renderer2, cd: ChangeDetectorRef, | |
private primeNgService: PrimeNgService, | |
@Inject(APP_CONFIG) private appConfig: CMSSAppConfig) { | |
super(el, domHandler, renderer, cd); | |
if (this.primeNgService.calendarSettingsLoaded) { | |
this.locale = this.primeNgService.calendarLocaleSettings; | |
this.dateFormat = this.primeNgService.calendarDateFormat; | |
} | |
} | |
writeValue(value: any): void { | |
// PrimeNG does not recognize ISO string value | |
if (typeof value === 'string') { | |
if (value.split('T').length > 1) { | |
value = new Date(value); | |
} | |
let valStr: string = String(value).replace(/[^\d]/gi, ''); | |
if (valStr.matches(/[\d]{6}/)) { | |
const yearPrefixe: string = String(new Date().getFullYear()).substr(0, 2); | |
valStr = valStr.substr(0, 4) + yearPrefixe + valStr.substr(4, 2); | |
} | |
// traiter la valStr (soit '05062019' soit '06052019') | |
const year: number = valStr.substr(4, 4); | |
// faire selon this.appConfig.affiliateLocales.AffiliatePrimeNgDateFormat (soit mm/dd/y, soit dd/mm/y) | |
} | |
super.writeValue(value); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment