diff options
author | Samuel Newman <mozzius@protonmail.com> | 2025-02-21 10:59:27 -0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2025-02-21 10:59:27 -0800 |
commit | fff625167f03c28168379de82a9b874b640d2605 (patch) | |
tree | 5cb4bfabb4e9168d42cc23859d9eb02aa3d84642 | |
parent | 5d30111b7832377637d0f3ebb533610375e4edb9 (diff) | |
download | voidsky-fff625167f03c28168379de82a9b874b640d2605.tar.zst |
set minimum birthday to 13 years ago (#7808)
-rw-r--r-- | src/components/dialogs/BirthDateSettings.tsx | 3 | ||||
-rw-r--r-- | src/lib/strings/time.ts | 11 |
2 files changed, 13 insertions, 1 deletions
diff --git a/src/components/dialogs/BirthDateSettings.tsx b/src/components/dialogs/BirthDateSettings.tsx index 9fbf378ac..fecfc43bc 100644 --- a/src/components/dialogs/BirthDateSettings.tsx +++ b/src/components/dialogs/BirthDateSettings.tsx @@ -4,6 +4,7 @@ import {msg, Trans} from '@lingui/macro' import {useLingui} from '@lingui/react' import {cleanError} from '#/lib/strings/errors' +import {getDateAgo} from '#/lib/strings/time' import {logger} from '#/logger' import {isIOS, isWeb} from '#/platform/detection' import { @@ -101,7 +102,7 @@ function BirthdayInner({ onChangeDate={newDate => setDate(new Date(newDate))} label={_(msg`Birthday`)} accessibilityHint={_(msg`Enter your birth date`)} - maximumDate={new Date()} + maximumDate={getDateAgo(13)} /> </View> 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 { |