mirror of
https://github.com/Radiquum/AniX.git
synced 2025-04-29 01:19:41 +05:00
feat: add user lists statistic with donut chart
This commit is contained in:
parent
5c23f204da
commit
6e8f03e7b6
9 changed files with 276 additions and 35 deletions
|
@ -172,18 +172,31 @@ export function sinceUnixDate(unixInSeconds: number) {
|
|||
);
|
||||
}
|
||||
|
||||
export function minutesToTime(min: number) {
|
||||
export function minutesToTime(
|
||||
min: number,
|
||||
type?: "full" | "daysOnly" | "daysHours"
|
||||
) {
|
||||
const d = Math.floor(min / 1440); // 60*24
|
||||
const h = Math.floor((min - d * 1440) / 60);
|
||||
const m = Math.round(min % 60);
|
||||
|
||||
var dDisplay =
|
||||
d > 0 ? `${d} ${numberDeclension(d, "день", "дня", "дней")}, ` : "";
|
||||
d > 0 ? `${d} ${numberDeclension(d, "день", "дня", "дней")}` : "";
|
||||
var hDisplay =
|
||||
h > 0 ? `${h} ${numberDeclension(h, "час", "часа", "часов")}, ` : "";
|
||||
h > 0 ? `${h} ${numberDeclension(h, "час", "часа", "часов")}` : "";
|
||||
var mDisplay =
|
||||
m > 0 ? `${m} ${numberDeclension(m, "минута", "минуты", "минут")}` : "";
|
||||
return dDisplay + hDisplay + mDisplay;
|
||||
|
||||
if (type == "daysOnly") {
|
||||
if (d > 0) return dDisplay;
|
||||
return "? дней";
|
||||
} else if (type == "daysHours") {
|
||||
if (d > 0 && h > 0) return dDisplay + ", " + hDisplay;
|
||||
if (h > 0) return hDisplay;
|
||||
if (m > 0) return mDisplay;
|
||||
} else {
|
||||
return `${dDisplay}${h > 0 && ", " + hDisplay}${m > 0 && ", " + mDisplay}`;
|
||||
}
|
||||
}
|
||||
|
||||
const StatusList: Record<string, null | number> = {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue