Horde_Timezone::_parse PHP Method

_parse() protected method

Parses a file from the timezone database.
protected _parse ( string $file )
$file string A file location.
    protected function _parse($file)
    {
        $stream = new Horde_Support_StringStream($file);
        $fp = $stream->fopen();
        $zone = null;
        while (($line = fgets($fp)) !== false) {
            $line = trim($line);
            if (!strlen($line) || $line[0] == '#') {
                continue;
            }
            $column = preg_split('/\\s+/', preg_replace('/\\s*#.*$/', '', $line));
            switch ($column[0]) {
                case 'Rule':
                    if (!isset($this->_rules[$column[1]])) {
                        $this->_rules[$column[1]] = new Horde_Timezone_Rule($column[1]);
                    }
                    $this->_rules[$column[1]]->add($column);
                    $zone = null;
                    break;
                case 'Link':
                    $this->_links[$column[2]] = $column[1];
                    $zone = null;
                    break;
                case 'Zone':
                    $zone = $column[1];
                    $this->_zones[$zone] = new Horde_Timezone_Zone($zone, $this);
                    array_splice($column, 0, 2);
                    // Fall through.
                // Fall through.
                default:
                    if (empty($zone) || !isset($this->_zones[$zone])) {
                        break;
                    }
                    $this->_zones[$zone]->add($column);
                    break;
            }
        }
    }