about summary refs log tree commit diff
path: root/src/lib/strings/time.ts
diff options
context:
space:
mode:
authorSamuel Newman <mozzius@protonmail.com>2025-02-21 10:59:27 -0800
committerGitHub <noreply@github.com>2025-02-21 10:59:27 -0800
commitfff625167f03c28168379de82a9b874b640d2605 (patch)
tree5cb4bfabb4e9168d42cc23859d9eb02aa3d84642 /src/lib/strings/time.ts
parent5d30111b7832377637d0f3ebb533610375e4edb9 (diff)
downloadvoidsky-fff625167f03c28168379de82a9b874b640d2605.tar.zst
set minimum birthday to 13 years ago (#7808)
Diffstat (limited to 'src/lib/strings/time.ts')
-rw-r--r--src/lib/strings/time.ts11
1 files changed, 11 insertions, 0 deletions
diff --git a/src/lib/strings/time.ts b/src/lib/strings/time.ts
index e505b7892..3823af188 100644
--- a/src/lib/strings/time.ts
+++ b/src/lib/strings/time.ts
@@ -20,6 +20,17 @@ export function getAge(birthDate: Date): number {
 }
 
 /**
+ * Get a Date object that is N years ago from now
+ * @param years number of years
+ * @returns Date object
+ */
+export function getDateAgo(years: number): Date {
+  const date = new Date()
+  date.setFullYear(date.getFullYear() - years)
+  return date
+}
+
+/**
  * Compares two dates by year, month, and day only
  */
 export function simpleAreDatesEqual(a: Date, b: Date): boolean {