• 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
class CI_Calendar->get_month_name() - Wrong month name for month May

#1
[eluser]fensen[/eluser]
Detected in CodeIgniter_1.6.3

$month_names[5] has the same value both in
month_type == 'short'
and
month_type == 'long'.

Code:
function get_month_name($month)
{
if ($this->month_type == 'short')
{
$month_names = array(
'01' => 'cal_jan',
'02' => 'cal_feb',
'03' => 'cal_mar',
'04' => 'cal_apr',
'05' => 'cal_may',
'06' => 'cal_jun',
'07' => 'cal_jul',
'08' => 'cal_aug',
'09' => 'cal_sep',
'10' => 'cal_oct',
'11' => 'cal_nov',
'12' => 'cal_dec'
);
}
else
{
$month_names = array(
'01' => 'cal_january',
'02' => 'cal_february',
'03' => 'cal_march',
'04' => 'cal_april',
'05' => 'cal_may',
'06' => 'cal_june',
'07' => 'cal_july',
'08' => 'cal_august',
'09' => 'cal_september',
'10' => 'cal_october',
'11' => 'cal_november',
'12' => 'cal_december'
);
}
...
}

According to "/language/xxx/calendar_lang.php", the long version should be 'cal_mayl' as follows:

Code:
if ($this->month_type == 'short')
{
  $month_names = array(
    ...
    '05' => 'cal_may',
    ...
  );
}
else
{
  $month_names = array(
    ...
    '05' => 'cal_mayl',
    ...
  );
}

In English it's not a problem because the name of the month "May" is the same, short or long version.

But in other languages it is an issue.

Thanks


Fabian

#2
[eluser]xwero[/eluser]
Nice catch but i think CI would be better off using the php functions set_locale and strftime. Then loading of a language file isn't needed to internationalize your app.
Code:
$display = ($this->month_type == 'short')?'%b':'%B';
$month_names = array();

for($i=1, $max=12;$i<=$max;$i++)
{
  $month_names[str_pad($i,2,0,STR_PAD_LEFT)] = strftime($display,mktime(0,0,0,$i,1,1970));
}


Digg   Delicious   Reddit   Facebook   Twitter   StumbleUpon  


  Theme © 2014 iAndrew  
Powered By MyBB, © 2002-2019 MyBB Group.