Esempio n. 1
0
    }
    //-----------------------------------------------------------------------
    /**
     * Outputs this period as a {@code String}, such as {@code P6Y3M1D}.
     * <p>
     * The output will be in the ISO-8601 period format.
     * A zero period will be represented as zero days, 'P0D'.
     *
     * @return string a string representation of this period, not null
     */
    public function __toString()
    {
        if ($this == self::$ZERO) {
            return "P0D";
        } else {
            $buf = 'P';
            if ($this->years != 0) {
                $buf .= $this->years . 'Y';
            }
            if ($this->months != 0) {
                $buf .= $this->months . 'M';
            }
            if ($this->days != 0) {
                $buf .= $this->days . 'D';
            }
            return $buf;
        }
    }
}
Period::init();