Commit e1cf1c4 1 parent 13bd6c3 commit e1cf1c4 Copy full SHA for e1cf1c4
File tree 1 file changed +15
-1
lines changed
1 file changed +15
-1
lines changed Original file line number Diff line number Diff line change 8
8
import NextLogo from " $lib/assets/logos/Nextjs-logo.svg?component" ;
9
9
import ReactLogo from " $lib/assets/logos/React-icon.svg?component" ;
10
10
import VueLogo from " $lib/assets/logos/Vue.js_Logo_2.svg?component" ;
11
+
12
+ const getAge = (dateString : string ) => {
13
+ var today = new Date ();
14
+ var birthDate = new Date (dateString );
15
+ var age = today .getFullYear () - birthDate .getFullYear ();
16
+ var m = today .getMonth () - birthDate .getMonth ();
17
+
18
+ if (m < 0 || (m === 0 && today .getDate () < birthDate .getDate ())) {
19
+ age -- ;
20
+ }
21
+
22
+ return age ;
23
+ }
24
+
11
25
</script >
12
26
13
27
<main >
14
28
<h1 >About me</h1 >
15
29
<article >
16
30
<p >Hello! My name is <b >Károly Sárdi</b >, also known as <b >skver</b >.</p >
17
31
<p >
18
- I'm a 20 years old student from Hungary, currently studying at the <br /> Eötvös
32
+ I'm a { getAge ( " 2003-02-25 " )} years old student from Hungary, currently studying at the <br /> Eötvös
19
33
Loránd University, Faculty of Informatics.
20
34
</p >
21
35
<p >
You can’t perform that action at this time.
0 commit comments