private function setDay($day) {
        
        //preventing duplication process
        if ($day == $this->day) {
            return;
        }
        $maximumDayOfMonth = static::getMonthLength($this->month, $this->year);
        $dayToSet          = $day;
        if ($dayToSet < 1) {
            
            $dayToSet = abs($dayToSet);
            
            while ($dayToSet > $maximumDayOfMonth) {
                $dayToSet -= $maximumDayOfMonth;
                $month    = $this->month - 1;
                $this->setMonth($month);
                $maximumDayOfMonth = static::getMonthLength($this->month, $this->year);
            }
            
            $dayToSet = $maximumDayOfMonth - $dayToSet;
            $month    = $this->month - 1;
            $this->setMonth($month);
            
        } elseif ($dayToSet > $maximumDayOfMonth) {
            while ($dayToSet > $maximumDayOfMonth) {
                $dayToSet -= $maximumDayOfMonth;
                $month    = $this->month + 1;
                $this->setMonth($month);
                $maximumDayOfMonth = static::getMonthLength($this->month, $this->year);
            }
        }
        
        $this->day = (int) $dayToSet;
    }
private function setDay($day) {
        
        //preventing duplication process
        if ($day == $this->day) {
            return;
        }
        $maximumDayOfMonth = static::getMonthLength($this->month, $this->year);
        $dayToSet          = $day;
        if ($dayToSet < 1) {
            
            $dayToSet = abs($dayToSet);
            
            while ($dayToSet > $maximumDayOfMonth) {
                $dayToSet -= $maximumDayOfMonth;
                $month    = $this->month - 1;
                $this->setMonth($month);
                $maximumDayOfMonth = static::getMonthLength($this->month, $this->year);
            }
            
            $dayToSet = $maximumDayOfMonth - $dayToSet;
            $month    = $this->month - 1;
            $this->setMonth($month);
            
        } elseif ($dayToSet > $maximumDayOfMonth) {
            while ($dayToSet > $maximumDayOfMonth) {
                $dayToSet -= $maximumDayOfMonth;
                $month    = $this->month + 1;
                $this->setMonth($month);
                $maximumDayOfMonth = static::getMonthLength($this->month, $this->year);
            }
        }
        
        $this->day = (int) $dayToSet;
    }
private function setDay ( $ day ) { //preventing duplication process if ( $ day == $ this -> day ) { return ; } $ maximumDayOfMonth = static :: getMonthLength ( $ this -> month , $ this -> year ) ; $ dayToSet = $ day ; if ( $ dayToSet < 1 ) { $ dayToSet = abs ( $ dayToSet ) ; while ( $ dayToSet > $ maximumDayOfMonth ) { $ dayToSet -= $ maximumDayOfMonth ; $ month = $ this -> month - 1 ; $ this -> setMonth ( $ month ) ; $ maximumDayOfMonth = static :: getMonthLength ( $ this -> month , $ this -> year ) ; } $ dayToSet = $ maximumDayOfMonth - $ dayToSet ; $ month = $ this -> month - 1 ; $ this -> setMonth ( $ month ) ; } elseif ( $ dayToSet > $ maximumDayOfMonth ) { while ( $ dayToSet > $ maximumDayOfMonth ) { $ dayToSet -= $ maximumDayOfMonth ; $ month = $ this -> month + 1 ; $ this -> setMonth ( $ month ) ; $ maximumDayOfMonth = static :: getMonthLength ( $ this -> month , $ this -> year ) ; } } $ this -> day = ( int ) $ dayToSet ; }
Update day in jalali date

@param int $day
Update day in jalali date