Closed thrashzone13 closed 3 years ago
Can you add the method and make a merge request?
Yes let me see if i can do it later on today.
I'm afraid I can't make a merge request. by the way I wrote the method
public function getWeekOfMonth(): int { $week = 1; for ($i = 1; $i <= $this->getMonthDays(); $i++) { if ($this->addDays($i)->isEndOfWeek()) $week++; if ($this->day == $i) return $week; } } I appreciate you add it if its correct
There is not any fear. you can write code and test. make MR when all tests pass.
BTW the problem might be solved by bellow code:
$weekOfMonth = (int) ceil($this->day / 7)
$weekOfMonth = (int) ceil($this->day / 7)
doesn't work correctly as months can have 4, 5 or 6 weeks
The following would get the job done
$offset = (new Jalalian($this->year, $this->month, 1))->getDayOfWeek();
$weekOfMonth = ceil(($offset + $this->day) / 7);
@hshahdoost It works fine tnx
@hshahdoost please make a merge request and add getWeekOfMonth()
method
Hi like carbon the weekOfMonth property is needed