mirror of
https://github.com/the-djmaze/snappymail.git
synced 2026-08-31 13:09:21 +03:00
Cleanup Date.fromNow() and friendlySize()
This commit is contained in:
parent
2bd9528098
commit
a0f8ac0dad
7 changed files with 28 additions and 50 deletions
|
|
@ -7,6 +7,7 @@ const
|
|||
msOffice = app+'vnd.openxmlformats-officedocument.',
|
||||
openDoc = app+'vnd.oasis.opendocument.',
|
||||
font = app+'x-font-',
|
||||
sizes = ['B', 'KiB', 'MiB', 'GiB', 'TiB'],
|
||||
|
||||
exts = {
|
||||
'eml': 'message/rfc822',
|
||||
|
|
@ -309,5 +310,12 @@ export const File = {
|
|||
}
|
||||
|
||||
return '';
|
||||
},
|
||||
|
||||
friendlySize: bytes => {
|
||||
bytes = parseInt(bytes, 10) || 0;
|
||||
let i = Math.floor(Math.log(bytes) / Math.log(1024));
|
||||
return (bytes / Math.pow(1024, i)).toFixed(2>i ? 0 : 1) + sizes[i];
|
||||
}
|
||||
|
||||
};
|
||||
|
|
|
|||
|
|
@ -99,16 +99,6 @@ export function inFocus() {
|
|||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {(number|string)} sizeInBytes
|
||||
* @returns {string}
|
||||
*/
|
||||
export function friendlySize(sizeInBytes) {
|
||||
sizeInBytes = pInt(sizeInBytes);
|
||||
const sizes = ['B', 'KiB', 'MiB', 'GiB', 'TiB'], i = pInt(Math.floor(Math.log(sizeInBytes) / Math.log(1024)));
|
||||
return (sizeInBytes / Math.pow(1024, i)).toFixed(2>i ? 0 : 1) + sizes[i];
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {string} theme
|
||||
* @returns {string}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue