From 7a176b3fdff7d27651b306e7550010b344dfa922 Mon Sep 17 00:00:00 2001 From: Paul Frazee Date: Mon, 8 May 2023 17:25:57 -0500 Subject: [APP-615] COPPA-compliant signup (#570) * Rework account creation to be COPPA compliant * Fix lint * Switch android datepicker to use the spinner mode * Fix type signatures & usages --- src/lib/strings/time.ts | 10 ++++++++++ 1 file changed, 10 insertions(+) (limited to 'src/lib/strings/time.ts') diff --git a/src/lib/strings/time.ts b/src/lib/strings/time.ts index 6cd70498e..588b84459 100644 --- a/src/lib/strings/time.ts +++ b/src/lib/strings/time.ts @@ -39,3 +39,13 @@ export function niceDate(date: number | string | Date) { minute: '2-digit', })}` } + +export function getAge(birthDate: Date): number { + var today = new Date() + var age = today.getFullYear() - birthDate.getFullYear() + var m = today.getMonth() - birthDate.getMonth() + if (m < 0 || (m === 0 && today.getDate() < birthDate.getDate())) { + age-- + } + return age +} -- cgit 1.4.1