Skip to content

Commit

Permalink
Quick fix
Browse files Browse the repository at this point in the history
  • Loading branch information
StaffCollab committed May 1, 2024
1 parent 588f62c commit ac919dc
Showing 1 changed file with 13 additions and 8 deletions.
21 changes: 13 additions & 8 deletions src/HebrewDate.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,13 @@ class HebrewDate extends Zman
{
public function addHebrewMonths(int $month = 1): self
{
$this->isJewishLeapYear() ? $months = 13 : $months = 12;

while ($month) {
$this->jewishMonth < $months ? $this->jewishMonth++ : ($this->jewishYear++ && $this->jewishMonth = 1);
$this->jewishMonth < 13 ? $this->jewishMonth++ : ($this->jewishYear++ && $this->jewishMonth = 1);

if ($this->jewishMonth == 6 && ! $this->isJewishLeapYear()) {
$this->jewishMonth++;
}

$month--;
}

Expand All @@ -23,10 +26,13 @@ public function addHebrewMonths(int $month = 1): self

public function subHebrewMonths(int $month = 1): self
{
$this->isJewishLeapYear() ? $months = 13 : $months = 12;

while ($month) {
$this->jewishMonth > 1 ? $this->jewishMonth-- : ($this->jewishYear-- && $this->jewishMonth = $months);
$this->jewishMonth > 1 ? $this->jewishMonth-- : ($this->jewishYear-- && $this->jewishMonth = 13);

if ($this->jewishMonth == 6 && ! $this->isJewishLeapYear()) {
$this->jewishMonth--;
}

$month--;
}

Expand Down Expand Up @@ -121,9 +127,8 @@ public function getHebrewMonthsPeriod($lang = 'hebrew'): Collection
$months = collect();

$this->startOfHebrewYear();
$count = $this->isJewishLeapYear() ? 13 : 12;

for ($i = 0; $i < $count; $i++) {
for ($i = 0; $i < 13; $i++) {
$months->push($lang == 'hebrew' ? $this->copy()->jewishMonthNameHebrew : $this->copy()->jewishMonthName);
$this->addHebrewMonths();
}
Expand Down

0 comments on commit ac919dc

Please sign in to comment.