11import { Component , forwardRef , OnInit } from '@angular/core'
22import { NG_VALUE_ACCESSOR } from '@angular/forms'
3- import { NgbDateParserFormatter } from '@ng-bootstrap/ng-bootstrap'
3+ import {
4+ NgbDateAdapter ,
5+ NgbDateParserFormatter ,
6+ } from '@ng-bootstrap/ng-bootstrap'
47import { SettingsService } from 'src/app/services/settings.service'
5- import { LocalizedDateParserFormatter } from 'src/app/utils/ngb-date-parser-formatter'
68import { AbstractInputComponent } from '../abstract-input'
79
810@Component ( {
@@ -23,7 +25,8 @@ export class DateComponent
2325{
2426 constructor (
2527 private settings : SettingsService ,
26- private ngbDateParserFormatter : NgbDateParserFormatter
28+ private ngbDateParserFormatter : NgbDateParserFormatter ,
29+ private isoDateAdapter : NgbDateAdapter < string >
2730 ) {
2831 super ( )
2932 }
@@ -43,9 +46,10 @@ export class DateComponent
4346 let pastedText = clipboardData . getData ( 'text' )
4447 pastedText = pastedText . replace ( / [ \s a - z # ! $ % \^ & \* ; : { } = \- _ ` ~ ( ) ] + / g, '' )
4548 const parsedDate = this . ngbDateParserFormatter . parse ( pastedText )
46- const formattedDate = this . ngbDateParserFormatter . format ( parsedDate )
47- this . writeValue ( formattedDate )
48- this . onChange ( formattedDate )
49+ if ( parsedDate ) {
50+ this . writeValue ( this . isoDateAdapter . toModel ( parsedDate ) )
51+ this . onChange ( this . value )
52+ }
4953 }
5054 }
5155
0 commit comments