/** * Refine data * * Not all data can be retrieved but some data can be guessed or assumed. * Try to fill in the blanks with the data that we already have. * * @return Mzax_GeoIp_Request */ public function refine() { // try to get region id from string if (!$this->regionId && $this->region && $this->countryId) { $this->regionId = Mzax_GeoIp_Region::getRegionCode($this->countryId, $this->region); } if (!$this->regionId && $this->countryId && preg_match('/^[A-Z0-9]{2,3}$/', $this->region)) { $this->regionId = $this->region; $this->region = Mzax_GeoIp_Region::getRegionCode($this->countryId, $this->regionId); } if (!$this->timeZone) { // try to get a time zone from the location, not perfect but will give us a rough idea $this->timeZone = Mzax_GeoIp_Region::getTimeZone($this->countryId, $this->regionId, $this->city); } if ($this->timeZone && $this->timeOffset === null) { try { $time = new DateTime("now", new DateTimeZone($this->timeZone)); $this->timeOffset = $time->getOffset() / -60; } catch (Exception $e) { } } return $this; }