Zend_Date_Exception example


    protected function setUnixTimestamp($timestamp = null)
    {
        $old = $this->_unixTimestamp;

        if (is_numeric($timestamp)) {
            $this->_unixTimestamp = $timestamp;
        } else if ($timestamp === null) {
            $this->_unixTimestamp = time();
        } else {
            throw new Zend_Date_Exception('\'' . $timestamp . '\' is not a valid UNIX timestamp', 0, null, $timestamp);
        }

        return $old;
    }

    /** * Returns this object's UNIX timestamp * A timestamp greater then the integer range will be returned as string * This function does not return the timestamp as object. Use copy() instead. * * @return integer|string timestamp */
if (empty($options)) {
            return self::$_options;
        }

        foreach ($options as $name => $value) {
            $name  = strtolower($name);

            if (array_key_exists($name, self::$_options)) {
                switch($name) {
                    case 'format_type' :
                        if ((strtolower($value) != 'php') && (strtolower($value) != 'iso')) {
                            throw new Zend_Date_Exception("Unknown format type ($value) for dates, only 'iso' and 'php' supported", 0, null, $value);
                        }
                        break;
                    case 'fix_dst' :
                        if (!is_bool($value)) {
                            throw new Zend_Date_Exception("'fix_dst' has to be boolean", 0, null, $value);
                        }
                        break;
                    case 'extend_month' :
                        if (!is_bool($value)) {
                            throw new Zend_Date_Exception("'extend_month' has to be boolean", 0, null, $value);
                        }
                        

    public static function City($city$horizon = false)
    {
        foreach (self::$cities as $key => $value) {
            if (strtolower($key) === strtolower($city)) {
                $return            = $value;
                $return['horizon'] = $horizon;
                return $return;
            }
        }
        throw new Zend_Date_Exception('unknown city');
    }

    /** * Return a list with all known cities * * @return array */
    public static function getCityList()
    {
        return array_keys(self::$cities);
    }
}
Home | Imprint | This part of the site doesn't use cookies.