Skip to content

Commit a694dc1

Browse files
committed
reverted min/max year limit
1 parent 776918c commit a694dc1

1 file changed

Lines changed: 5 additions & 2 deletions

File tree

  • src/components/DatePicker/CalendarPicker

src/components/DatePicker/CalendarPicker/index.tsx

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import {addMonths, addYears, format, isSameDay, parseISO, setDate, setMonth, setYear, startOfDay, subMonths, subYears} from 'date-fns';
1+
import {addMonths, addYears, format, getYear, isSameDay, parseISO, setDate, setMonth, setYear, startOfDay, subMonths, subYears} from 'date-fns';
22
import {Str} from 'expensify-common';
33
import React, {useCallback, useEffect, useRef, useState} from 'react';
44
import type {StyleProp, ViewStyle} from 'react-native';
@@ -81,8 +81,11 @@ function CalendarPicker({
8181
const initialHeight = (calendarDaysMatrix?.length || CONST.MAX_CALENDAR_PICKER_ROWS) * CONST.CALENDAR_PICKER_DAY_HEIGHT;
8282
const heightValue = useSharedValue(initialHeight);
8383

84+
const minYear = Math.min(getYear(new Date(minDate)), CONST.CALENDAR_PICKER.MIN_YEAR);
85+
const maxYear = Math.max(getYear(new Date(maxDate)), CONST.CALENDAR_PICKER.MAX_YEAR);
86+
8487
const [years, setYears] = useState<CalendarPickerListItem[]>(() =>
85-
Array.from({length: CONST.CALENDAR_PICKER.MAX_YEAR - CONST.CALENDAR_PICKER.MIN_YEAR + 1}, (v, i) => i + CONST.CALENDAR_PICKER.MIN_YEAR).map((year) => ({
88+
Array.from({length: maxYear - minYear + 1}, (v, i) => i + minYear).map((year) => ({
8689
text: year.toString(),
8790
value: year,
8891
keyForList: year.toString(),

0 commit comments

Comments
 (0)