diff --git a/src/components/dialogs/BirthDateSettings.tsx b/src/components/dialogs/BirthDateSettings.tsx index 9fbf378ace..fecfc43bc1 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)} /> diff --git a/src/lib/strings/time.ts b/src/lib/strings/time.ts index e505b7892e..3823af1882 100644 --- a/src/lib/strings/time.ts +++ b/src/lib/strings/time.ts @@ -19,6 +19,17 @@ export function getAge(birthDate: Date): number { return age } +/** + * 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 */