From c879b3f36139548338cab3a02fcd878c252f7a49 Mon Sep 17 00:00:00 2001
From: Kai Reinhard <K.Reinhard@micromata.de>
Date: Sun, 16 Dec 2018 15:54:51 +0000
Subject: [PATCH] humanFileSize...
---
borgbutler-webapp/src/utilities/global.js | 12 ++++++++++--
1 files changed, 10 insertions(+), 2 deletions(-)
diff --git a/borgbutler-webapp/src/utilities/global.js b/borgbutler-webapp/src/utilities/global.js
index 310d76a..119a74d 100644
--- a/borgbutler-webapp/src/utilities/global.js
+++ b/borgbutler-webapp/src/utilities/global.js
@@ -41,11 +41,19 @@
//return date.toLocaleDateString("de-DE", options);
}
-export const humanFileSize = (size) => {
+export const humanFileSize = (size, hideZero, suppressSeparatorChar) => {
+ if (size == null || isNaN(size)) return '';
+ if (size === 0) {
+ if (hideZero) {
+ return '';
+ }
+ return '0';
+ }
+ const sepChar = suppressSeparatorChar ? '' : ' ';
const i = Math.floor(Math.log(size) / Math.log(1024));
const amount = size / Math.pow(1024, i);
const digits = amount < 10 ? 2 : (amount < 100 ? 1 : 0);
- return amount.toLocaleString(undefined, {maximumFractionDigits: digits}) + ' ' + ['B', 'kB', 'MB', 'GB', 'TB'][i];
+ return amount.toLocaleString(undefined, {maximumFractionDigits: digits}) + sepChar + ['', 'kB', 'MB', 'GB', 'TB'][i];
}
export const humanSeconds = (secondsValue) => {
--
Gitblit v1.10.0