Human-readable sizes
This commit is contained in:
@@ -6,6 +6,14 @@ export function determineFileType(inputString: string): "file" | "folder" {
|
||||
}
|
||||
}
|
||||
|
||||
export function formatSize(size: number) {
|
||||
for (const unit of [null, 'kB', 'MB', 'GB', 'TB', 'PB', 'EB']) {
|
||||
if (size < 1e5) return size.toLocaleString().replace(',', '\u202F') + (unit ? `\u202F${unit}` : '')
|
||||
size = Math.round(size / 1000)
|
||||
}
|
||||
return "huge"
|
||||
}
|
||||
|
||||
export function formatUnixDate(t: number) {
|
||||
const date = new Date(t * 1000)
|
||||
const now = new Date()
|
||||
|
||||
Reference in New Issue
Block a user