set minimum birthday to 13 years ago (#7808)

This commit is contained in:
Samuel Newman
2025-02-21 10:59:27 -08:00
committed by GitHub
parent 5d30111b78
commit fff625167f
2 changed files with 13 additions and 1 deletions
+2 -1
View File
@@ -4,6 +4,7 @@ import {msg, Trans} from '@lingui/macro'
import {useLingui} from '@lingui/react' import {useLingui} from '@lingui/react'
import {cleanError} from '#/lib/strings/errors' import {cleanError} from '#/lib/strings/errors'
import {getDateAgo} from '#/lib/strings/time'
import {logger} from '#/logger' import {logger} from '#/logger'
import {isIOS, isWeb} from '#/platform/detection' import {isIOS, isWeb} from '#/platform/detection'
import { import {
@@ -101,7 +102,7 @@ function BirthdayInner({
onChangeDate={newDate => setDate(new Date(newDate))} onChangeDate={newDate => setDate(new Date(newDate))}
label={_(msg`Birthday`)} label={_(msg`Birthday`)}
accessibilityHint={_(msg`Enter your birth date`)} accessibilityHint={_(msg`Enter your birth date`)}
maximumDate={new Date()} maximumDate={getDateAgo(13)}
/> />
</View> </View>
+11
View File
@@ -19,6 +19,17 @@ export function getAge(birthDate: Date): number {
return age 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 * Compares two dates by year, month, and day only
*/ */