coachcare / npm-datepicker

Material Datepicker Fork with TimePicker by CoachCare
MIT License
32 stars 18 forks source link

AM/PM selector always shown #36

Closed Mef45 closed 5 years ago

Mef45 commented 5 years ago

I use ru-RU locale, which isn't has AM/PM selector, but it always visible even if i add twelveHour="false" to <mat-datepicker>

Angular version is 7.2.6

Here is part of my code

<mat-form-field fxFlex>
<input matInput [matDatepicker]="datepickerFrom" placeholder="Choose a date" formControlName="dateFrom"
                 required>
<mat-datepicker-toggle matSuffix [for]="datepickerFrom"></mat-datepicker-toggle>
<mat-datepicker #datepickerFrom type="datetime" clockStep="5" twelveHour="false"></mat-datepicker>
</mat-form-field>
import { DateAdapter, MAT_DATE_FORMATS, MAT_DATE_LOCALE, MomentDateAdapter } from '@coachcare/datepicker';
import { CUSTOM_DATE_FORMAT } from './customDateFormat';
[...]
providers: [
    { provide: DateAdapter, useClass: MomentDateAdapter },
    { provide: MAT_DATE_FORMATS, useValue: CUSTOM_DATE_FORMAT },
    { provide: MAT_DATE_LOCALE, useValue: 'ru-RU' }
  ]
import { MatDatepickerModule, MatMomentDateModule } from '@coachcare/datepicker';
import { MatDateFormats } from '@coachcare/datepicker';

export const CUSTOM_DATE_FORMAT: MatDateFormats = {
  parse: {
    date: ['YYYY-MM-DD', 'YYYY/MM/DD', 'll'],
    datetime: ['YYYY-MM-DD HH:mm', 'YYYY/MM/DD HH:mm', 'll HH:mm'],
    time: ['H:mm', 'HH:mm']
  },
  display: {
    date: 'DD.MM.YYYY',
    datetime: 'DD.MM.YYYY HH:mm',
    time: 'HH:mm',
    dateA11yLabel: 'HH:mm',
    monthDayLabel: 'MMM D',
    monthDayA11yLabel: 'MMMM D',
    monthYearLabel: 'MMMM YYYY',
    monthYearA11yLabel: 'MMMM YYYY',
    timeLabel: 'HH:mm'
  }
};

What am i doing wrong?

image

elcarlo1986 commented 5 years ago

Hello! First time contributing! I used this and it worked! Hope it helps! <mat-datepicker type="datetime" [twelveHour]="false" #picker></mat-datepicker>