Add me.mjs with age()

master
Raymonzut 4 years ago
parent 7506909670
commit 2c7f327892
No known key found for this signature in database
GPG Key ID: 1E9BCC39EDD1DD53
  1. 17
      client/public/lib/me.mjs

@ -0,0 +1,17 @@
export function age() {
let birthdate = new Date(2002, 8, 29)
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…
Cancel
Save