Skip to content

Commit

Permalink
fixed english ordinal
Browse files Browse the repository at this point in the history
  • Loading branch information
Tino Ehrich committed Mar 31, 2015
1 parent f11e145 commit 9d580ef
Showing 1 changed file with 15 additions and 4 deletions.
19 changes: 15 additions & 4 deletions src/Locales/en_GB.php
Original file line number Diff line number Diff line change
Expand Up @@ -36,10 +36,21 @@
"ordinal" => function ($number)
{
$b = $number % 10;
$output = (~~($number % 100 / 10) === 1) ? 'th' :
($b === 1) ? 'st' :
($b === 2) ? 'nd' :
($b === 3) ? 'rd' : 'th';

switch ($b)

This comment has been minimized.

Copy link
@edu2004eu

edu2004eu Apr 8, 2015

Is this working for values between 10 and 19? Doesn't seem to me from reading the code, but maybe I'm missing something.

What worked for me (I have an older version) was to modify the old code to include some brackets:

        $b = $number % 10;
        $output = (~~($number % 100 / 10) === 1) ? 'th' :
            (($b === 1) ? 'st' :
                (($b === 2) ? 'nd' :
                    (($b === 3) ? 'rd' : 'th')));

        return $number . "[$output]";

This comment has been minimized.

Copy link
@fightbulc

fightbulc Apr 8, 2015

Owner

Hey there. You are correct. There is indeed an issue for numbers between 11 - 13. Just added a new release. Thanks for spotting this. Cheers

{
case 1:
$output = 'st';
break;
case 2:
$output = 'nd';
break;
case 3:
$output = 'rd';
break;
default:
$output = 'th';
}

return $number . "[$output]";
},
Expand Down

0 comments on commit 9d580ef

Please sign in to comment.