src/Peach/DT/SimpleFormat.php
private function formatKey(Time $d, $key)
    {
        $year  = $d->get("year");
        $month = $d->get("month");
        $date  = $d->get("date");
        $hour  = $d->get("hour");
        $min   = $d->get("minute");
        $sec   = $d->get("second");
        
        switch ($key) {
            case "Y":
                return str_pad($year,  4, "0", STR_PAD_LEFT);
            case "m":
                return str_pad($month, 2, "0", STR_PAD_LEFT);
            case "n":
                return $month;
            case "d":
                return str_pad($date,  2, "0", STR_PAD_LEFT);
            case "j":
                return $date;
            case "H":
                return str_pad($hour,  2, "0", STR_PAD_LEFT);
            case "G":
                return $hour;
            case "i":
                return str_pad($min,   2, "0", STR_PAD_LEFT);
            case "f":
                return $min;
            case "s":
                return str_pad($sec,   2, "0", STR_PAD_LEFT);
            case "b":
                return $sec;
            case "E":
                return $this->dayList[$d->getDay()];
        }
        
        // @codeCoverageIgnoreStart
        throw new \Exception("Illegal pattern: " . $key);
        // @codeCoverageIgnoreEnd
    }
private function formatKey(Time $d, $key)
    {
        $year  = $d->get("year");
        $month = $d->get("month");
        $date  = $d->get("date");
        $hour  = $d->get("hour");
        $min   = $d->get("minute");
        $sec   = $d->get("second");
        
        switch ($key) {
            case "Y":
                return str_pad($year,  4, "0", STR_PAD_LEFT);
            case "m":
                return str_pad($month, 2, "0", STR_PAD_LEFT);
            case "n":
                return $month;
            case "d":
                return str_pad($date,  2, "0", STR_PAD_LEFT);
            case "j":
                return $date;
            case "H":
                return str_pad($hour,  2, "0", STR_PAD_LEFT);
            case "G":
                return $hour;
            case "i":
                return str_pad($min,   2, "0", STR_PAD_LEFT);
            case "f":
                return $min;
            case "s":
                return str_pad($sec,   2, "0", STR_PAD_LEFT);
            case "b":
                return $sec;
            case "E":
                return $this->dayList[$d->getDay()];
        }
        
        // @codeCoverageIgnoreStart
        throw new \Exception("Illegal pattern: " . $key);
        // @codeCoverageIgnoreEnd
    }
指定されたパターン文字を, 対応するフィールドの値に変換します.

@param  Time   $d   変換対象の時間オブジェクト
@param  string $key パターン文字 ("Y", "m", "d" など)
@return int         変換結果
@throws \Exception  不正なパターン文字が指定された場合