From 209777f6854330ba3a5dbd7b694f9d81b89871cb Mon Sep 17 00:00:00 2001 From: Damien Carcel Date: Mon, 23 Dec 2024 14:34:52 +0100 Subject: [PATCH] feat(#87): calculate my age Also format automatically my birth date. Will be usefull when CV will be dispayed in French too. --- package.json | 2 +- src/app/cv/page.tsx | 14 +++++++++++++- 2 files changed, 14 insertions(+), 2 deletions(-) diff --git a/package.json b/package.json index eff5119..c9baa78 100644 --- a/package.json +++ b/package.json @@ -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" }, diff --git a/src/app/cv/page.tsx b/src/app/cv/page.tsx index d54d12d..d09b9d2 100644 --- a/src/app/cv/page.tsx +++ b/src/app/cv/page.tsx @@ -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 (
@@ -32,7 +44,7 @@ export default function Cv() { { title: 'Phone', value: { main: '+33 6 20 45 25 55' } }, { title: 'Email', value: { main: 'damien.carcel@gmail.com' } }, { 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)' } }, ]} />