Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Code optimizations.
  • Loading branch information
resurtm committed Aug 25, 2012
1 parent 8264bc4 commit ffe1711
Showing 1 changed file with 3 additions and 6 deletions.
9 changes: 3 additions & 6 deletions framework/utils/CDateTimeParser.php
Expand Up @@ -305,27 +305,24 @@ protected static function parseAmPm($value, $offset)
*/
protected static function parseMonth($value, $offset, $width, &$monthName)
{
$valueLength=mb_strlen($value);
for($len=1; ; $len++)
for($len=1; $offset+$len<=mb_strlen($value); $len++)
{
$monthName=mb_substr($value, $offset, $len);
if(!preg_match('/^\p{L}+$/u', $monthName)) // unicode aware replacement for ctype_alpha($monthName)
{
$monthName=mb_substr($monthName, 0, -1);
break;
}
if($offset+$len==$valueLength)
break;
}
$monthName=mb_strtolower($monthName);

$monthNames=Yii::app()->getLocale()->getMonthNames($width, false);
foreach($monthNames as $k=>$v)
$monthNames[$k]=trim(mb_strtolower($v), '.');
$monthNames[$k]=rtrim(mb_strtolower($v), '.');

$monthNamesStandAlone=Yii::app()->getLocale()->getMonthNames($width, true);
foreach($monthNamesStandAlone as $k=>$v)
$monthNamesStandAlone[$k]=trim(mb_strtolower($v), '.');
$monthNamesStandAlone[$k]=rtrim(mb_strtolower($v), '.');

if(($v=array_search($monthName, $monthNames))===false && ($v=array_search($monthName, $monthNamesStandAlone))===false)
return false;
Expand Down

0 comments on commit ffe1711

Please sign in to comment.