Skip to content
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

fix(moment date service): use locale format by default #2856

Merged
merged 3 commits into from
Sep 15, 2021

Conversation

katebatura
Copy link
Contributor

@katebatura katebatura commented Sep 3, 2021

Please read and mark the following check list before creating a pull request:

Short description of what this resolves:

When manually typing the date into the input field, the DatePicker uses the provided DateFormat.

How to use:

@NgModule({
  imports: [
    NbDatepickerModule.forRoot(),
    NbMomentDateModule,
    ...
  ],
  providers: [{provide: LOCALE_ID, useValue: 'ru-RU'}],
})

Closes #2080

@katebatura katebatura requested a review from yggg September 3, 2021 14:12
@yggg yggg changed the title fix(nb-datepicker): formatting date with moment fix(datepicker): formatting date with moment Sep 14, 2021
@@ -184,15 +184,15 @@ export class NbMomentDateService extends NbDateService<Moment> {
}

isValidDateString(date: string, format: string): boolean {
return moment(date, format).isValid();
return moment(date, format || this.localeData.defaultFormat).isValid();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's reuse this.parse. And please check other adapters implementations.

@yggg yggg changed the title fix(datepicker): formatting date with moment fix(datepicker): use locale format by default Sep 14, 2021
@yggg yggg changed the title fix(datepicker): use locale format by default fix(moment date service): use locale format by default Sep 14, 2021
@yggg yggg merged commit 491c696 into akveo:master Sep 15, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

NbDatePicker input ignores DateFormat
2 participants