Skip to content

Commit

Permalink
add week when last day of month is also end of week+1
Browse files Browse the repository at this point in the history
  • Loading branch information
nathanstitt committed Oct 28, 2021
1 parent cf66cc5 commit d9f95a2
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 4 deletions.
10 changes: 9 additions & 1 deletion demo.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ class DayzTestComponent extends React.Component {
this.editComponent = this.editComponent.bind(this);
this.changeDisplay = this.changeDisplay.bind(this);
this.onEventResize = this.onEventResize.bind(this);
const date = moment('2015-09-11');
const date = moment('2021-10-08');
this.state = {
date,
display: 'month',
Expand Down Expand Up @@ -83,11 +83,19 @@ class DayzTestComponent extends React.Component {
);
}

setDate = (ev) => {
const dte = moment(ev.target.value);
if (dte.isValid()) {
this.setState({ ...this.state, date: moment(ev.target.value) });
}
}

render() {
return (
<div className="dayz-test-wrapper">

<div className="tools">
<input type="text" onBlur={this.setDate} defaultValue={this.state.date.format('YYYY-MM-DD')} />
<label>
Month: <input type="radio"
name="style" value="month" onChange={this.changeDisplay}
Expand Down
8 changes: 5 additions & 3 deletions src/api/layout.js
Original file line number Diff line number Diff line change
Expand Up @@ -95,9 +95,11 @@ export default class Layout {
this.range.start.subtract(
startWeekday, 'days',
);
this.range.end.add(
maxWeekday - this.range.end.isoWeekday(), 'days',
);

const additionalDays = (maxWeekday + 1 === this.range.end.isoWeekday())
? 6 : (maxWeekday - this.range.end.isoWeekday());

this.range.end.add(additionalDays, 'days');
}
}

Expand Down

0 comments on commit d9f95a2

Please sign in to comment.