mirror of
https://github.com/skidoodle/albert.lol.git
synced 2025-02-15 06:09:15 +01:00
app router
This commit is contained in:
commit
156764768d
27 changed files with 10813 additions and 0 deletions
19
src/app/utils/index.ts
Normal file
19
src/app/utils/index.ts
Normal file
|
@ -0,0 +1,19 @@
|
|||
export default function age() {
|
||||
const BIRTHDATE = process.env.NEXT_PUBLIC_BIRTHDATE;
|
||||
if (!BIRTHDATE) {
|
||||
console.warn("Missing environment variable: BIRTHDATE");
|
||||
return 0;
|
||||
}
|
||||
|
||||
return Math.floor(
|
||||
(new Date().getTime() - new Date(BIRTHDATE).getTime()) / 3.15576e10,
|
||||
);
|
||||
}
|
||||
|
||||
export const truncate = (str: string, n: number): string => {
|
||||
if (str.length > n) {
|
||||
const truncated = str.slice(0, n - 3).trimEnd();
|
||||
return `${truncated}...`;
|
||||
}
|
||||
return str.trim();
|
||||
};
|
Loading…
Add table
Add a link
Reference in a new issue