Skip to content

Commit

Permalink
Fix initialDates shift bug (#77)
Browse files Browse the repository at this point in the history
  • Loading branch information
pdpino authored Apr 16, 2021

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature.
1 parent 80fdf0b commit 0a583a5
Showing 2 changed files with 7 additions and 7 deletions.
7 changes: 6 additions & 1 deletion src/WeekView/WeekView.js
Original file line number Diff line number Diff line change
@@ -242,8 +242,13 @@ export default class WeekView extends Component {

calculatePagesDates = (currentMoment, numberOfDays, prependMostRecent) => {
const initialDates = [];
const centralDate = moment(currentMoment);
if (numberOfDays === 7) {
// Start week on monday
centralDate.startOf('isoWeek');
}
for (let i = -this.pageOffset; i <= this.pageOffset; i += 1) {
const initialDate = moment(currentMoment).add(numberOfDays * i, 'd');
const initialDate = moment(centralDate).add(numberOfDays * i, 'd');
initialDates.push(initialDate.format(DATE_STR_FORMAT));
}
return prependMostRecent ? initialDates.reverse() : initialDates;
7 changes: 1 addition & 6 deletions src/utils.js
Original file line number Diff line number Diff line change
@@ -29,12 +29,7 @@ export const getCurrentMonth = (date) => {

export const calculateDaysArray = (date, numberOfDays, rightToLeft) => {
const dates = [];
let initial = 0;
if (numberOfDays === 7) {
initial = 1;
initial -= moment(date).isoWeekday();
}
for (let i = initial; i < numberOfDays + initial; i += 1) {
for (let i = 0; i < numberOfDays; i += 1) {
const currentDate = moment(date).add(i, 'd');
dates.push(currentDate);
}

0 comments on commit 0a583a5

Please sign in to comment.