fix: birthday

This commit is contained in:
kieran 2024-12-16 15:08:46 +00:00
parent c13cf88ce2
commit 53b64165db
No known key found for this signature in database
GPG Key ID: DE71CEB3925BE941

View File

@ -9,10 +9,25 @@ import useLogin from "../../Hooks/useLogin";
import { isBirthday, isChristmas, isHalloween, isStPatricksDay } from "../../Utils";
import { getCurrentSubscription } from "../../Utils/Subscription";
function ordinal_suffix_of(i: number) {
const j = i % 10;
const k = i % 100;
if (j === 1 && k !== 11) {
return i + "st";
}
if (j === 2 && k !== 12) {
return i + "nd";
}
if (j === 3 && k !== 13) {
return i + "rd";
}
return i + "th";
}
const getExtra = () => {
if (isBirthday()) {
const age = (unixNowMs() - Birthday.getTime()) / (Day * 365_000);
return <span className="text-xs">{age.toFixed(0)}st 🎂</span>;
const age = Math.floor((unixNowMs() - Birthday.getTime()) / (Day * 365_000));
return <span className="text-xs">{ordinal_suffix_of(age)} 🎂</span>;
}
if (isHalloween()) return <span title="Happy Halloween!">🎃</span>;
if (isStPatricksDay()) return <span title="Happy St. Patrick's Day!">🍀</span>;