parent
6c31c8752d
commit
a0eb56e115
4 changed files with 1 additions and 32 deletions
@ -1,4 +0,0 @@ |
|||||||
import { age } from "./lib/me.mjs" |
|
||||||
|
|
||||||
const age_span = document.getElementById("age") |
|
||||||
age_span.textContent = age().toString() |
|
@ -1,17 +0,0 @@ |
|||||||
export function age() { |
|
||||||
let birthdate = new Date("29 August 2002") |
|
||||||
let now = new Date() |
|
||||||
|
|
||||||
let age = now.getFullYear() - birthdate.getFullYear() |
|
||||||
|
|
||||||
if (now.getMonth() < birthdate.getMonth()) |
|
||||||
age-- |
|
||||||
|
|
||||||
if ( |
|
||||||
birthdate.getMonth() === now.getMonth() && |
|
||||||
now.getDate() < birthdate.getDate() |
|
||||||
) |
|
||||||
age-- |
|
||||||
|
|
||||||
return age |
|
||||||
} |
|
Loading…
Reference in new issue