mirror of
https://gh-proxy.org/https://github.com/tiajinsha/JKVideo
synced 2026-07-08 15:33:51 +08:00
feat: add all source files - services, store, hooks, components, screens
This commit is contained in:
16
utils/format.ts
Normal file
16
utils/format.ts
Normal file
@@ -0,0 +1,16 @@
|
||||
export function formatCount(n: number): string {
|
||||
if (n >= 100_000_000) return (n / 100_000_000).toFixed(1) + '亿';
|
||||
if (n >= 10_000) return (n / 10_000).toFixed(1) + '万';
|
||||
return String(n);
|
||||
}
|
||||
|
||||
export function formatDuration(seconds: number): string {
|
||||
const m = Math.floor(seconds / 60);
|
||||
const s = seconds % 60;
|
||||
return `${m}:${String(s).padStart(2, '0')}`;
|
||||
}
|
||||
|
||||
export function formatTime(ctime: number): string {
|
||||
const d = new Date(ctime * 1000);
|
||||
return `${d.getFullYear()}-${String(d.getMonth() + 1).padStart(2, '0')}-${String(d.getDate()).padStart(2, '0')}`;
|
||||
}
|
||||
Reference in New Issue
Block a user