Skip to content

Commit

Permalink
fix: locale filesize formatting
Browse files Browse the repository at this point in the history
  • Loading branch information
dromzeh committed Jul 11, 2024
1 parent 23f0157 commit 12e06bc
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 12 deletions.
9 changes: 0 additions & 9 deletions src/components/asset/download-indicator.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,15 +9,6 @@ import {
import {
DropdownMenu,
DropdownMenuContent,
// DropdownMenuGroup,
// DropdownMenuItem,
// DropdownMenuLabel,
// DropdownMenuPortal,
// DropdownMenuSeparator,
// DropdownMenuShortcut,
// DropdownMenuSub,
// DropdownMenuSubContent,
// DropdownMenuSubTrigger,
DropdownMenuTrigger,
} from "~/components/ui/dropdown-menu";
import { FormatGameName, FormatCategoryName } from "~/lib/format";
Expand Down
7 changes: 4 additions & 3 deletions src/lib/format.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,9 @@ export function bytesToFileSize(bytes: number) {
const sizes = ["B", "KB", "MB", "GB", "TB"];
if (bytes === 0) return "0 B";
const i = Math.floor(Math.log2(bytes) / 10);
const size = (bytes / 1024 ** i).toFixed(1);
const formatter = new Intl.NumberFormat("default", {
maximumFractionDigits: 1,
});
const size = formatter.format(bytes / 1024 ** i);
return `${size} ${sizes[i]}`;
}

// i need to figure out img res

0 comments on commit 12e06bc

Please sign in to comment.