about summary refs log tree commit diff
path: root/src/lib/strings/time.ts
diff options
context:
space:
mode:
authorPaul Frazee <pfrazee@gmail.com>2023-05-08 17:25:57 -0500
committerGitHub <noreply@github.com>2023-05-08 17:25:57 -0500
commit7a176b3fdff7d27651b306e7550010b344dfa922 (patch)
tree368d255a28b4b8e445ee66ff7278c792acc40703 /src/lib/strings/time.ts
parentcdfb1c7abf02ef7896d6cdcf3566ee0c7dd390d3 (diff)
downloadvoidsky-7a176b3fdff7d27651b306e7550010b344dfa922.tar.zst
[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
Diffstat (limited to 'src/lib/strings/time.ts')
-rw-r--r--src/lib/strings/time.ts10
1 files changed, 10 insertions, 0 deletions
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
+}