Skip to content

Commit

Permalink
fixed thousands
Browse files Browse the repository at this point in the history
  • Loading branch information
petrparolek committed Dec 29, 2017
1 parent 6a05abd commit 7251586
Showing 1 changed file with 27 additions and 0 deletions.
27 changes: 27 additions & 0 deletions src/Utils/CzechNumber2Words.php
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,33 @@ public static function number2Words($number, $units = null, $level = -1)
$string .= self::number2words($remainder, null, $level);
}
break;
case $number < 10000:
$thousands = floor($number / 1000);
$remainder = $number % 1000;
if($thousands == 1){
$dict = '';
if(!$level){
$dict = $dictionary[$thousands];
if($number < 2000){
$dict = 'jeden'; // jedentisicstodvanact
}
}
}elseif($thousands == 2){
$dict = 'dva';
}else{
$dict = $dictionary[$thousands];
}
if($thousands == 5) {
$string = $dict . "tisíc";
} elseif($thousands > 1) {
$string = $dict . "tisíce";
} else {
$string = $dict . $dictionary['1000'];
}
if ($remainder) {
$string .= self::number2words($remainder, null, $level);
}
break;
default:
$baseUnit = pow(1000, floor(log($number, 1000)));
$numBaseUnits = (int) ($number / $baseUnit);
Expand Down

0 comments on commit 7251586

Please sign in to comment.