|
|
@@ -749,21 +749,54 @@ class Zend_Locale_Format
|
|
|
return null;
|
|
|
}
|
|
|
|
|
|
- $convert = array('d' => 'dd' , 'D' => 'EE' , 'j' => 'd' , 'l' => 'EEEE', 'N' => 'eee' , 'S' => 'SS' ,
|
|
|
- 'w' => 'e' , 'z' => 'D' , 'W' => 'ww' , 'F' => 'MMMM', 'm' => 'MM' , 'M' => 'MMM' ,
|
|
|
- 'n' => 'M' , 't' => 'ddd' , 'L' => 'l' , 'o' => 'YYYY', 'Y' => 'yyyy', 'y' => 'yy' ,
|
|
|
- 'a' => 'a' , 'A' => 'a' , 'B' => 'B' , 'g' => 'h' , 'G' => 'H' , 'h' => 'hh' ,
|
|
|
- 'H' => 'HH' , 'i' => 'mm' , 's' => 'ss' , 'e' => 'zzzz', 'I' => 'I' , 'O' => 'Z' ,
|
|
|
- 'P' => 'ZZZZ', 'T' => 'z' , 'Z' => 'X' , 'c' => 'yyyy-MM-ddTHH:mm:ssZZZZ',
|
|
|
- 'r' => 'r' , 'U' => 'U');
|
|
|
- $values = str_split($format);
|
|
|
- foreach ($values as $key => $value) {
|
|
|
- if (isset($convert[$value]) === true) {
|
|
|
- $values[$key] = $convert[$value];
|
|
|
+ $convert = array(
|
|
|
+ 'd' => 'dd' , 'D' => 'EE' , 'j' => 'd' , 'l' => 'EEEE',
|
|
|
+ 'N' => 'eee' , 'S' => 'SS' , 'w' => 'e' , 'z' => 'D' ,
|
|
|
+ 'W' => 'ww' , 'F' => 'MMMM', 'm' => 'MM' , 'M' => 'MMM' ,
|
|
|
+ 'n' => 'M' , 't' => 'ddd' , 'L' => 'l' , 'o' => 'YYYY',
|
|
|
+ 'Y' => 'yyyy', 'y' => 'yy' , 'a' => 'a' , 'A' => 'a' ,
|
|
|
+ 'B' => 'B' , 'g' => 'h' , 'G' => 'H' , 'h' => 'hh' ,
|
|
|
+ 'H' => 'HH' , 'i' => 'mm' , 's' => 'ss' , 'e' => 'zzzz',
|
|
|
+ 'I' => 'I' , 'O' => 'Z' , 'P' => 'ZZZZ', 'T' => 'z' ,
|
|
|
+ 'Z' => 'X' , 'c' => 'yyyy-MM-ddTHH:mm:ssZZZZ', 'r' => 'r',
|
|
|
+ 'U' => 'U',
|
|
|
+ );
|
|
|
+ $escaped = false;
|
|
|
+ $inEscapedString = false;
|
|
|
+ $converted = array();
|
|
|
+ foreach (str_split($format) as $char) {
|
|
|
+ if (!$escaped && $char == '\\') {
|
|
|
+ // Next char will be escaped: let's remember it
|
|
|
+ $escaped = true;
|
|
|
+ } elseif ($escaped) {
|
|
|
+ if (!$inEscapedString) {
|
|
|
+ // First escaped string: start the quoted chunk
|
|
|
+ $converted[] = "'";
|
|
|
+ $inEscapedString = true;
|
|
|
+ }
|
|
|
+ // Since the previous char was a \ and we are in the quoted
|
|
|
+ // chunk, let's simply add $char as it is
|
|
|
+ $converted[] = $char;
|
|
|
+ $escaped = false;
|
|
|
+ } elseif ($char == "'") {
|
|
|
+ // Single quotes need to be escaped like this
|
|
|
+ $converted[] = "''";
|
|
|
+ } else {
|
|
|
+ if ($inEscapedString) {
|
|
|
+ // Close the single-quoted chunk
|
|
|
+ $converted[] = "'";
|
|
|
+ $inEscapedString = false;
|
|
|
+ }
|
|
|
+ // Convert the unescaped char if needed
|
|
|
+ if (isset($convert[$char])) {
|
|
|
+ $converted[] = $convert[$char];
|
|
|
+ } else {
|
|
|
+ $converted[] = $char;
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- return implode($values);
|
|
|
+ return implode($converted);
|
|
|
}
|
|
|
|
|
|
/**
|