src/Marando/AstroDate/AstroDate.php
public function setTimezone($timezone)
    {
        // Check type, and parse string if present
        if (is_string($timezone)) {
            $timezone = TimeZone::parse($timezone);
        } else {
            if ($timezone instanceof TimeZone == false) {
                throw new \InvalidArgumentException();
            }
        }

        // Convert back to UTC
        //$this->toUTC();
        // Compute new UTC offset
        $jd       = $this->toJD();
        $tzOffset = $timezone->offset($jd) - $this->timezone->offset($jd);

        $this->add(Time::hours($tzOffset));

        // Set the timezone
        $this->timezone  = $timezone;
        $this->timezone0 = $timezone;

        return $this;
    }
public function setTimezone($timezone)
    {
        // Check type, and parse string if present
        if (is_string($timezone)) {
            $timezone = TimeZone::parse($timezone);
        } else {
            if ($timezone instanceof TimeZone == false) {
                throw new \InvalidArgumentException();
            }
        }

        // Convert back to UTC
        //$this->toUTC();
        // Compute new UTC offset
        $jd       = $this->toJD();
        $tzOffset = $timezone->offset($jd) - $this->timezone->offset($jd);

        $this->add(Time::hours($tzOffset));

        // Set the timezone
        $this->timezone  = $timezone;
        $this->timezone0 = $timezone;

        return $this;
    }
public function setTimezone ( $ timezone ) { // Check type, and parse string if present if ( is_string ( $ timezone ) ) { $ timezone = TimeZone :: parse ( $ timezone ) ; } else { if ( $ timezone instanceof TimeZone == false ) { throw new \ InvalidArgumentException ( ) ; } } // Convert back to UTC //$this->toUTC(); // Compute new UTC offset $ jd = $ this -> toJD ( ) ; $ tzOffset = $ timezone -> offset ( $ jd ) - $ this -> timezone -> offset ( $ jd ) ; $ this -> add ( Time :: hours ( $ tzOffset ) ) ; // Set the timezone $ this -> timezone = $ timezone ; $ this -> timezone0 = $ timezone ; return $ this ; }
Sets the time zone of this instance

@param  TimeZone|string $timezone Either a TimeZone instance or string

@return static

@throws InvalidArgumentException Occurs if the timezone is an invalid
type
Sets the time zone of this instance