Skip to content

Commit

Permalink
build: release @matheo/datepicker v11.2.14
Browse files Browse the repository at this point in the history
Fix DateFnsAdapter issues
  • Loading branch information
matheo committed May 23, 2021
1 parent 8da5d4d commit b2e12ba
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 10 deletions.
4 changes: 2 additions & 2 deletions apps/website/src/app/demos/demos.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { NgModule, NO_ERRORS_SCHEMA } from '@angular/core';
import { FlexLayoutModule } from '@angular/flex-layout';
import { RouterModule, Routes } from '@angular/router';
import { MatDatepickerModule } from '@matheo/datepicker';
import { MatLuxonDateModule } from '@matheo/datepicker/luxon';
import { MatDateFnsModule } from '@matheo/datepicker/date-fns';
import { ThemeComponent } from '../shared/layout/theme/theme.component';
import { SharedModule } from '../shared/shared.module';
import { DatepickerComponent } from './components/datepicker/datepicker.component';
Expand Down Expand Up @@ -47,7 +47,7 @@ const routes: Routes = [
FlexLayoutModule,
RouterModule.forChild(routes),
MatDatepickerModule,
MatLuxonDateModule,
MatDateFnsModule,
SharedModule,
],
declarations: [IndexComponent, DatepickerComponent],
Expand Down
22 changes: 15 additions & 7 deletions libs/datepicker/date-fns/date-fns-adapter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -191,11 +191,11 @@ export class DateFnsAdapter extends DateAdapter<Date> {
}

getHourNames(): string[] {
return range(0, 24).map((i) => (i === 0 ? '00' : String(i)));
return range(0, 23).map((i) => (i === 0 ? '00' : String(i)));
}

getMinuteNames(): string[] {
return range(0, 31).map((i) => String(i + 1));
return range(0, 59).map(String);
}

getDayOfWeekNames(style: 'long' | 'short' | 'narrow'): string[] {
Expand Down Expand Up @@ -252,7 +252,15 @@ export class DateFnsAdapter extends DateAdapter<Date> {
throw Error(`Invalid date "${date}". Date has to be greater than 0.`);
}

const result = this._createDateWithOverflow(year, month, date);
const result = this._createDateWithOverflow(
year,
month,
date,
hours,
minutes,
seconds,
ms
);
// Check that the date wasn't above the upper bound for the month, causing the month to overflow
if (result.getMonth() !== month) {
throw Error(`Invalid date "${date}" for month with index "${month}".`);
Expand Down Expand Up @@ -357,10 +365,10 @@ export class DateFnsAdapter extends DateAdapter<Date> {
year: number,
month: number,
date: number,
hours?: number,
minutes?: number,
seconds?: number,
ms?: number
hours: number = 0,
minutes: number = 0,
seconds: number = 0,
ms: number = 0
): Date {
const result = this._createDateInternal(
year,
Expand Down
2 changes: 1 addition & 1 deletion libs/datepicker/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@matheo/datepicker",
"version": "11.2.13",
"version": "11.2.14",
"description": "Angular material date+time picker",
"keywords": [
"angular",
Expand Down

0 comments on commit b2e12ba

Please sign in to comment.