Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Wrong weekOfMonth for a date #145

Closed
aramhuseiny opened this issue Apr 20, 2022 · 2 comments
Closed

Wrong weekOfMonth for a date #145

aramhuseiny opened this issue Apr 20, 2022 · 2 comments

Comments

@aramhuseiny
Copy link

Hi,
Thank you for this powerful package you made.

I try to use weekOfMonth method for a specific date, but I found there is a mistake in the formula that calculates that.

@aramhuseiny
Copy link
Author

I checked the formula,
This is the current one that calculates wrong
ceil(($this->getDayOfWeek() + $this->day) / 7);
I think you can use this that I suggest:
floor(($this->day + 7 - $this->getDayOfWeek()) / 7) + 1

@aramhuseiny
Copy link
Author

aramhuseiny commented Apr 20, 2022

Actually the base value of "7" is not valid in all cases.
New formula should be like this:
floor(($this->day + 5 - $this->getDayOfWeek()) / 7) + 1

morilog pushed a commit that referenced this issue Apr 26, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant