diff --git a/src/view/com/auth/create/Step2.tsx b/src/view/com/auth/create/Step2.tsx index 89fd070a..123b5f66 100644 --- a/src/view/com/auth/create/Step2.tsx +++ b/src/view/com/auth/create/Step2.tsx @@ -13,6 +13,17 @@ import {isWeb} from 'platform/detection' import {Trans, msg} from '@lingui/macro' import {useLingui} from '@lingui/react' import {useModalControls} from '#/state/modals' +import {logger} from '#/logger' + +function sanitizeDate(date: Date): Date { + if (!date || date.toString() === 'Invalid Date') { + logger.error(`Create account: handled invalid date for birthDate`, { + hasDate: !!date, + }) + return new Date() + } + return date +} /** STEP 2: Your account * @field Invite code or waitlist @@ -38,6 +49,10 @@ export function Step2({ openModal({name: 'waitlist'}) }, [openModal]) + const birthDate = React.useMemo(() => { + return sanitizeDate(uiState.birthDate) + }, [uiState.birthDate]) + return ( @@ -122,8 +137,9 @@ export function Step2({ Your birth date uiDispatch({type: 'set-birth-date', value})} buttonType="default-light" buttonStyle={[pal.border, styles.dateInputButton]} diff --git a/src/view/com/modals/BirthDateSettings.tsx b/src/view/com/modals/BirthDateSettings.tsx index c78f06ed..1505d224 100644 --- a/src/view/com/modals/BirthDateSettings.tsx +++ b/src/view/com/modals/BirthDateSettings.tsx @@ -23,7 +23,7 @@ import { } from '#/state/queries/preferences' import {logger} from '#/logger' -export const snapPoints = ['50%'] +export const snapPoints = ['50%', '90%'] function Inner({preferences}: {preferences: UsePreferencesQueryResponse}) { const pal = usePalette('default') @@ -63,6 +63,7 @@ function Inner({preferences}: {preferences: UsePreferencesQueryResponse}) { { + return new Intl.DateTimeFormat(LOCALE.languageTag, { + timeZone: props.handleAsUTC ? 'UTC' : undefined, + }) + }, [props.handleAsUTC]) + const onChangeInternal = useCallback( (event: DateTimePickerEvent, date: Date | undefined) => { setShow(false) @@ -64,7 +74,7 @@ export function DateInput(props: Props) { - {props.value.toLocaleDateString()} + {formatter.format(props.value)} @@ -73,6 +83,7 @@ export function DateInput(props: Props) {