Skip to content

Commit

Permalink
feat(#87): calculate my age
Browse files Browse the repository at this point in the history
Also format automatically my birth date. Will be usefull when CV will be
dispayed in French too.
  • Loading branch information
damien-carcel committed Dec 23, 2024
1 parent 7884973 commit 209777f
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 2 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
"lint": "next lint",
"prettier": "prettier '**/*.{js,jsx,mjs,ts,tsx}'",
"stylelint": "stylelint '**/*.css'",
"test": "jest --watch",
"test": "jest --watchAll",
"test:ci": "jest --ci",
"typecheck": "tsc -b"
},
Expand Down
14 changes: 13 additions & 1 deletion src/app/cv/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,18 @@ export const metadata: Metadata = {
*/

export default function Cv() {
const birthDate = new Date(1982, 2, 28);
const now = new Date();
const age = now.getFullYear() - birthDate.getFullYear();

const birthdateFormat: Intl.DateTimeFormatOptions = {
year: 'numeric',
month: 'long',
day: 'numeric',
};

const formattedBirthDate = new Intl.DateTimeFormat('en-US', birthdateFormat).format(birthDate);

return (
<div className={styles.main}>
<div className={styles.container}>
Expand All @@ -32,7 +44,7 @@ export default function Cv() {
{ title: 'Phone', value: { main: '+33 6 20 45 25 55' } },
{ title: 'Email', value: { main: '[email protected]' } },
{ title: 'Nationality', value: { main: 'French' } },
{ title: 'Date of birth', value: { main: 'March 28, 1982 (42 years old)' } },
{ title: 'Date of birth', value: { main: formattedBirthDate + ' (' + age + ' years old)' } },
]}
/>
<Section
Expand Down

0 comments on commit 209777f

Please sign in to comment.