public function format($data) { $prefix = $this->options['prefix']; $date = array(); if ($data['data']['year']) { $value = $data['data']['year']; $date["y"] = $data['data']['year']; } else { // use leap year, for correct formating 29 Febrary $value = date("Y"); while (!date("L", strtotime("{$value}-01-01"))) { $value += 1; } } if ($data['data']['month']) { $value .= "-" . ($data['data']['month'] < 10 ? "0" : "") . $data['data']['month']; $date["f"] = $data['data']['month']; } else { $value .= "-01"; } if ($data['data']['day']) { $value .= "-" . ($data['data']['day'] < 10 ? "0" : "") . $data['data']['day']; $date["j"] = $data['data']['day']; } else { $value .= "-01"; } $format = array(); foreach (explode(" ", waDateTime::getFormat('humandate')) as $p) { $f = strtolower(substr($p, 0, 1)); if (isset($date[$f])) { $format[] = $p; } } $format = implode(" ", $format); $format = preg_replace("/[^yfj]\$/i", "", $format); $date_time = new DateTime($value); // hack to insert month name in lower case if (strpos($format, 'f') !== false) { $format = str_replace('f', '@F@', $format); } $result = $date_time->format($format); // hack to insert localized month name if (strpos($format, 'F') !== false) { $month = $date_time->format('F'); $local = _ws($month, $month, strpos($format, 'j') !== false ? 2 : 1); $result = str_replace(array("@{$month}@", $month), array(mb_strtolower($local), $local), $result); } return $result; }