mirror of
https://github.com/Sendouc/sendou.ink.git
synced 2026-04-10 20:30:53 -05:00
47 lines
1.0 KiB
TypeScript
47 lines
1.0 KiB
TypeScript
export const getLocalizedMonthYearString = (
|
|
month: number,
|
|
year: number,
|
|
locale: string
|
|
) => {
|
|
const dateForLocalization = new Date();
|
|
dateForLocalization.setDate(1);
|
|
dateForLocalization.setMonth(month - 1);
|
|
dateForLocalization.setFullYear(year);
|
|
return dateForLocalization.toLocaleString(locale, {
|
|
month: "long",
|
|
year: "numeric",
|
|
});
|
|
};
|
|
|
|
export const getRankingString = (ranking: number) => {
|
|
switch (ranking) {
|
|
case 1:
|
|
return "🥇";
|
|
case 2:
|
|
return "🥈";
|
|
case 3:
|
|
return "🥉";
|
|
|
|
default:
|
|
return `${ranking}`;
|
|
}
|
|
};
|
|
|
|
// User attributes - should be virtuals in future if support gets added to Prisma
|
|
|
|
export const getFullUsername = ({
|
|
username,
|
|
discriminator,
|
|
}: {
|
|
username: string;
|
|
discriminator: string;
|
|
}) => `${username}#${discriminator}`;
|
|
|
|
export const getProfilePath = ({
|
|
discordId,
|
|
customUrlPath,
|
|
}: {
|
|
discordId: string;
|
|
customUrlPath: string | null | undefined;
|
|
}) => (customUrlPath ? `/u/${customUrlPath}` : `/u/${discordId}`);
|