Skip to content

Commit

Permalink
Clean up after PR
Browse files Browse the repository at this point in the history
  • Loading branch information
simeg committed Nov 15, 2016
1 parent c306f2f commit b8112dd
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 5 deletions.
12 changes: 9 additions & 3 deletions src/MonthsView.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,10 +27,14 @@ var DateTimePickerMonths = React.createClass({
classes, props
;

var currentMonth, disabled,
// Date is irrelevant because we're really only interested in month
irrelevantDate = 1;
while (i < 12) {
classes = 'rdtMonth';
var currentMonth = this.props.viewDate.clone().set({ year: year, month: i, date: 1 });
var disabled = !isValid(currentMonth);
currentMonth =
this.props.viewDate.clone().set({ year: year, month: i, date: irrelevantDate });
disabled = !isValid(currentMonth);

if ( disabled )
classes += ' rdtDisabled';
Expand All @@ -45,7 +49,8 @@ var DateTimePickerMonths = React.createClass({
};

if ( !disabled )
props.onClick = this.props.updateOn === 'months'? this.updateSelectedMonth : this.props.setDate('month');
props.onClick = (this.props.updateOn === 'months' ?
this.updateSelectedMonth : this.props.setDate('month'));

months.push( renderer( props, i, year, date && date.clone() ));

Expand All @@ -71,6 +76,7 @@ var DateTimePickerMonths = React.createClass({
: monthsShort[ month ]
);
},

isValidDate: function(){
return 1;
}
Expand Down
10 changes: 8 additions & 2 deletions src/YearsView.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,13 +28,19 @@ var DateTimePickerYears = React.createClass({
;

year--;
var currentYear, disabled,
// Month and date are irrelevant here because
// we're only really interested in the year
irrelevantMonth = 1,
irrelevantDate = 1;
while (i < 11) {
classes = 'rdtYear';
var currentYear = this.props.viewDate.clone().set({ year: year, month: 1, date: 1 });
currentYear = this.props.viewDate.clone().set(
{ year: year, month: irrelevantMonth, date: irrelevantDate });
if ( i === -1 | i === 10 )
classes += ' rdtOld';

var disabled = !isValid(currentYear);
disabled = !isValid(currentYear);
if ( disabled )
classes += ' rdtDisabled';

Expand Down

0 comments on commit b8112dd

Please sign in to comment.