diff --git a/application/helpers/locale_helper.php b/application/helpers/locale_helper.php index 15edbc3b8..e31f45e37 100644 --- a/application/helpers/locale_helper.php +++ b/application/helpers/locale_helper.php @@ -113,71 +113,8 @@ function quantity_decimals() /* - * Matches each symbol of PHP date format standard - * with jQuery equivalent codeword - * @author Tristan Jahier + * Time locale conversion utility */ -function dateformat_jquery($php_format) -{ - $SYMBOLS_MATCHING = array( - // Day - 'd' => 'dd', - 'D' => 'D', - 'j' => 'd', - 'l' => 'DD', - 'N' => '', - 'S' => '', - 'w' => '', - 'z' => 'o', - // Week - 'W' => '', - // Month - 'F' => 'MM', - 'm' => 'mm', - 'M' => 'M', - 'n' => 'm', - 't' => '', - // Year - 'L' => '', - 'o' => '', - 'Y' => 'yy', - 'y' => 'y', - // Time - 'a' => 'tt', - 'A' => 'TT', - 'B' => '', - 'g' => 'h', - 'G' => 'H', - 'h' => 'hh', - 'H' => 'HH', - 'i' => 'mm', - 's' => 'ss', - 'u' => '' - ); - - $jqueryui_format = ""; - $escaping = false; - for($i = 0; $i < strlen($php_format); $i++) - { - $char = $php_format[$i]; - if($char === '\\') // PHP date format escaping character - { - $i++; - if($escaping) $jqueryui_format .= $php_format[$i]; - else $jqueryui_format .= '\'' . $php_format[$i]; - $escaping = true; - } - else - { - if($escaping) { $jqueryui_format .= "'"; $escaping = false; } - if(isset($SYMBOLS_MATCHING[$char])) - $jqueryui_format .= $SYMBOLS_MATCHING[$char]; - else - $jqueryui_format .= $char; - } - } - return $jqueryui_format; -} function dateformat_momentjs($php_format) { @@ -262,29 +199,7 @@ function dateformat_bootstrap($php_format) 'u' => '' ); - $bootstrap_format = ""; - $escaping = false; - for($i = 0; $i < strlen($php_format); $i++) - { - $char = $php_format[$i]; - if($char === '\\') // PHP date format escaping character - { - $i++; - if($escaping) $bootstrap_format .= $php_format[$i]; - else $bootstrap_format .= '\'' . $php_format[$i]; - $escaping = true; - } - else - { - if($escaping) { $bootstrap_format .= "'"; $escaping = false; } - if(isset($SYMBOLS_MATCHING[$char])) - $bootstrap_format .= $SYMBOLS_MATCHING[$char]; - else - $bootstrap_format .= $char; - } - } - - return $bootstrap_format; + return strtr($php_format, $SYMBOLS_MATCHING); } ?>