stephy / CalendarPicker

CalendarPicker Component for React Native
792 stars 369 forks source link

startOnMonday = true shifts all days by 1 if first of month is sunday #118

Closed taimot closed 6 years ago

taimot commented 6 years ago

Hi there,

In this month (April 2018) all days are wrong by 1 day if startOnMonday is set, because the first row of the dayGrid doesn't begin with sunday in version 5.18.0.

Replacing the line 54 in DaysGridView.js let startIndex = (startFromMonday) ? (firstWeekDay - 1) % 7 : firstWeekDay; with let startIndex = (startFromMonday) ? ((firstWeekDay - 1) + 7) % 7 : firstWeekDay;

fixes this issue, because startIndex was -1 if first of month was sunday. Now it is 6.

peacechen commented 6 years ago

There is also a discussion about this in #49. The PR was never updated to account for the startFromMonday prop.

It looks like your code could be simplified to

let startIndex = (startFromMonday) ? (firstWeekDay + 6) % 7 : firstWeekDay;

I'd like some more testing on that before implementing that change. Would you mind submitting a PR?

v1kt0r1337 commented 6 years ago

I still have this issue now in July using version 5.19.0.

peacechen commented 6 years ago

Until it's published, you can use it by pointing the package.json directly to this repo.

  "dependencies": {
    "react-native-calendar-picker": "https://github.com/stephy/CalendarPicker"
    ...
  }

Would you mind trying it out and reporting back whether it fixes the issue you're seeing?

v1kt0r1337 commented 6 years ago

Hi,

Thanks for the response. I actually did this yesterday "react-native-calendar-picker": "stephy/CalendarPicker#master", and it solved my problem perfectly.


Fra: Peace notifications@github.com Sendt: tirsdag 17. juli 2018 19.27 Til: stephy/CalendarPicker Kopi: Archheretic; Comment Emne: Re: [stephy/CalendarPicker] startOnMonday = true shifts all days by 1 if first of month is sunday (#118)

Until it's published, you can use it by pointing the package.json directly to this repo.

"dependencies": { "react-native-calendar-picker": "https://github.com/stephy/CalendarPicker" ... }

Would you mind trying it out and reporting back whether it fixes the issue you're seeing?

— You are receiving this because you commented. Reply to this email directly, view it on GitHubhttps://github.com/stephy/CalendarPicker/issues/118#issuecomment-405661756, or mute the threadhttps://github.com/notifications/unsubscribe-auth/AKQBhFzzhFoc91OObfiHD2jsvpK9iRdaks5uHh5qgaJpZM4TTAND.

peacechen commented 6 years ago

5.20.0 has been published on npm 🍻

v1kt0r1337 commented 6 years ago

Nice! 🍻


Fra: Peace notifications@github.com Sendt: onsdag 18. juli 2018 17.53 Til: stephy/CalendarPicker Kopi: Archheretic; Comment Emne: Re: [stephy/CalendarPicker] startOnMonday = true shifts all days by 1 if first of month is sunday (#118)

5.20.0 has been published on npm 🍻

— You are receiving this because you commented. Reply to this email directly, view it on GitHubhttps://github.com/stephy/CalendarPicker/issues/118#issuecomment-405981241, or mute the threadhttps://github.com/notifications/unsubscribe-auth/AKQBhM0R2_LpQFvW_YTrwm5QMtfT73MZks5uH1nvgaJpZM4TTAND.