[eluser]Denzel[/eluser]
I was roaming about the CodeIgniter core just to familiarize myself and I came across some code in date_helper.php, specifically in the
timespan function, that I just cannot wrap my head around:
Code:
if ($years > 0 OR $months > 0)
{
if ($months > 0)
{
$str .= $months.' '.$CI->lang->line((($months > 1) ? 'date_months' : 'date_month')).', ';
}
$seconds -= $months * 2628000;
}
That's just one piece of it. Why are there two
if statements? It can be condensed into one, albeit senseless, statement:
Code:
if ($years > 0 OR $months > 0 AND $months > 0)
In its current state, I don't even know why
$years is involved, unless the author was going for a short-circuit statement in which case this would be the best option:
Code:
if ($years > 0 AND $months > 0)
Can anyone shed some light on this situation? I've looked it over a few times, maybe I'm missing something.