summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorGravatar Alexandre Alapetite <alexandre@alapetite.fr> 2014-01-26 17:11:24 +0100
committerGravatar Alexandre Alapetite <alexandre@alapetite.fr> 2014-01-26 17:11:24 +0100
commit1031c19779d4cd6764dab6fbc8360cc99ff83409 (patch)
treeaf1b5c6a084e70b00c53455cc7231f89a8366d33 /lib
parent004a652f8ae7d6b63ecf9f27ce2d12a4c69b110c (diff)
Formatage nombres
Implémente https://github.com/marienfressinaud/FreshRSS/issues/395
Diffstat (limited to 'lib')
-rw-r--r--lib/lib_rss.php7
1 files changed, 6 insertions, 1 deletions
diff --git a/lib/lib_rss.php b/lib/lib_rss.php
index ba5b01112..28cd99874 100644
--- a/lib/lib_rss.php
+++ b/lib/lib_rss.php
@@ -62,6 +62,11 @@ function small_hash ($txt) {
return strtr ($t, '+/', '-_');
}
+function formatNumber($n, $precision = 0) {
+ return str_replace(' ', '&#8239;', //Espace fine insécable
+ number_format($n, $precision, '.', ' ')); //number_format does not seem to be Unicode-compatible
+}
+
function formatBytes($bytes, $precision = 2, $system = 'IEC') {
if ($system === 'IEC') {
$base = 1024;
@@ -74,7 +79,7 @@ function formatBytes($bytes, $precision = 2, $system = 'IEC') {
$pow = $bytes === 0 ? 0 : floor(log($bytes) / log($base));
$pow = min($pow, count($units) - 1);
$bytes /= pow($base, $pow);
- return round($bytes, $precision) . ' ' . $units[$pow];
+ return formatNumber($bytes, $precision) . ' ' . $units[$pow];
}
function timestamptodate ($t, $hour = true) {