From 60fbcb8a0c35497f952931fa3812eb7d63b4c510 Mon Sep 17 00:00:00 2001 From: migueldeoleiros Date: Sun, 6 Jul 2025 00:36:37 +0200 Subject: [PATCH 1/3] feat: add check for day instead of full year --- src/components/Intro/index.tsx | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/src/components/Intro/index.tsx b/src/components/Intro/index.tsx index 9d82efd..3eddcfa 100644 --- a/src/components/Intro/index.tsx +++ b/src/components/Intro/index.tsx @@ -2,8 +2,18 @@ import React, {ReactNode} from 'react'; import Link from '@docusaurus/Link'; import styles from './styles.module.css'; -const currentYear = new Date().getFullYear(); -const yearsSince = currentYear - 1998; +const startDate = new Date(1998, 5, 22); // los meses empiezan en 0 +const today = new Date(); + +let yearsSince = today.getFullYear() - startDate.getFullYear(); + +const hasHadAnniversary = + today.getMonth() > startDate.getMonth() || + (today.getMonth() === startDate.getMonth() && today.getDate() >= startDate.getDate()); + +if (!hasHadAnniversary) { + yearsSince -= 1; +} export default function Intro(): ReactNode { return ( From 55099dd7c846de2040880140a854776a708f8a7f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Miguel=20L=C3=B3pez=20L=C3=B3pez?= Date: Sun, 6 Jul 2025 22:26:40 +0200 Subject: [PATCH 2/3] refactor: optimize age calculation on a single line Co-authored-by: Jorge Teixeira --- src/components/Intro/index.tsx | 13 +------------ 1 file changed, 1 insertion(+), 12 deletions(-) diff --git a/src/components/Intro/index.tsx b/src/components/Intro/index.tsx index 3eddcfa..b3301da 100644 --- a/src/components/Intro/index.tsx +++ b/src/components/Intro/index.tsx @@ -2,18 +2,7 @@ import React, {ReactNode} from 'react'; import Link from '@docusaurus/Link'; import styles from './styles.module.css'; -const startDate = new Date(1998, 5, 22); // los meses empiezan en 0 -const today = new Date(); - -let yearsSince = today.getFullYear() - startDate.getFullYear(); - -const hasHadAnniversary = - today.getMonth() > startDate.getMonth() || - (today.getMonth() === startDate.getMonth() && today.getDate() >= startDate.getDate()); - -if (!hasHadAnniversary) { - yearsSince -= 1; -} +const years = new Date(Date.now() - new Date(1998, 5, 22)).getUTCFullYear() - 1970 export default function Intro(): ReactNode { return ( From 2524c9749f451a0cd977d611cbf8f04cfd4ba1ee Mon Sep 17 00:00:00 2001 From: migueldeoleiros Date: Fri, 11 Jul 2025 11:00:37 +0200 Subject: [PATCH 3/3] fix: variable name mismatch --- src/components/Intro/index.tsx | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/components/Intro/index.tsx b/src/components/Intro/index.tsx index b3301da..0ae1a63 100644 --- a/src/components/Intro/index.tsx +++ b/src/components/Intro/index.tsx @@ -1,8 +1,8 @@ -import React, {ReactNode} from 'react'; +import React, { ReactNode } from 'react'; import Link from '@docusaurus/Link'; import styles from './styles.module.css'; -const years = new Date(Date.now() - new Date(1998, 5, 22)).getUTCFullYear() - 1970 +const yearsSince = new Date(Date.now() - new Date(1998, 5, 22).getTime()).getUTCFullYear() - 1970 export default function Intro(): ReactNode { return (