Skip to content

Commit

Permalink
fix(datepicker): if min date is last day of a month (#3113)
Browse files Browse the repository at this point in the history
user should be able to navigate into

fixes #3102
  • Loading branch information
valorkin authored Nov 27, 2017
1 parent a72fedc commit ec445e2
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 6 deletions.
1 change: 1 addition & 0 deletions src/datepicker/engine/flag-days-calendar.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import { isSameDay, isSameMonth } from '../../bs-moment/utils/date-getters';
import { isAfter, isBefore } from '../../bs-moment/utils/date-compare';
import { isMonthDisabled } from '../utils/bs-calendar-utils';
import { shiftDate } from '../../bs-moment/utils/date-setters';
import { endOf, startOf } from '../../bs-moment/utils/start-end-of';

export interface FlagDaysCalendarOptions {
isDisabled: boolean;
Expand Down
12 changes: 6 additions & 6 deletions src/datepicker/utils/bs-calendar-utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ import {
} from '../../bs-moment/utils/date-getters';
import { shiftDate } from '../../bs-moment/utils/date-setters';
import {
isSameOrAfter,
isSameOrBefore
isAfter,
isBefore
} from '../../bs-moment/utils/date-compare';
import { endOf, startOf } from '../../bs-moment/utils/start-end-of';

Expand All @@ -32,15 +32,15 @@ export function calculateDateOffset(weekday: number, startingDayOffset: number):
}

export function isMonthDisabled(date: Date, min: Date, max: Date): boolean {
const minBound = min && isSameOrBefore(endOf(date, 'month'), min, 'day');
const maxBound = max && isSameOrAfter(startOf(date, 'month'), max, 'day');
const minBound = min && isBefore(endOf(date, 'month'), min, 'day');
const maxBound = max && isAfter(startOf(date, 'month'), max, 'day');

return minBound || maxBound;
}

export function isYearDisabled(date: Date, min: Date, max: Date): boolean {
const minBound = min && isSameOrBefore(endOf(date, 'year'), min, 'day');
const maxBound = max && isSameOrAfter(startOf(date, 'year'), max, 'day');
const minBound = min && isBefore(endOf(date, 'year'), min, 'day');
const maxBound = max && isAfter(startOf(date, 'year'), max, 'day');

return minBound || maxBound;
}

0 comments on commit ec445e2

Please sign in to comment.