Skip to content

Commit

Permalink
fix: conflicts and linting
Browse files Browse the repository at this point in the history
  • Loading branch information
farhoudshapouran committed Sep 15, 2024
1 parent 4c7cacd commit a9da6c8
Show file tree
Hide file tree
Showing 6 changed files with 16 additions and 22 deletions.
3 changes: 1 addition & 2 deletions example/src/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -190,11 +190,10 @@ export default function App() {
startDate={range.startDate}
endDate={range.endDate}
dates={dates}
//isDateDisabled={(date) => [0, 6].includes(dayjs(date).day())} // disable weekends
//minDate={dayjs().startOf('day')}
//maxDate={dayjs().add(3, 'day').endOf('day')}
//disabledDates={[dayjs(), dayjs().add(1, 'day')]}
//disabledDates={(date) => [0, 6].includes(dayjs(date).day())}// disable weekends
//disabledDates={(date) => [0, 6].includes(dayjs(date).day())} // disable weekends
//firstDayOfWeek={1}
displayFullDays
timePicker={timePicker}
Expand Down
6 changes: 2 additions & 4 deletions src/DateTimePicker.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -81,10 +81,11 @@ const DateTimePicker = (
onChange,
initialView = 'day',
height,
isDateDisabled,
...rest
} = props;

dayjs.locale(locale);

const initialCalendarView: CalendarViews =
mode !== 'single' && initialView === 'time' ? 'day' : initialView;

Expand Down Expand Up @@ -113,8 +114,6 @@ const DateTimePicker = (

let currentYear = currentDate.year();

dayjs.locale(locale);

const [state, dispatch] = useReducer(
(prevState: LocalState, action: CalendarAction) => {
switch (action.type) {
Expand Down Expand Up @@ -310,7 +309,6 @@ const DateTimePicker = (
onSelectYear,
onChangeMonth,
onChangeYear,
isDateDisabled,
}}
>
<Calendar
Expand Down
10 changes: 6 additions & 4 deletions src/components/DaySelector.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -50,15 +50,16 @@ const DaySelector = () => {
minDate,
maxDate,
firstDayOfWeek,
disabledDates,
firstDayOfWeek
disabledDates
).map((day, index) => {
if (day) {
let leftCrop = day.dayOfMonth === 1;
let rightCrop = day.dayOfMonth === fullDaysInMonth;

const isFirstDayOfMonth = day.dayOfMonth === 1;
const isLastDayOfMonth = ((day?.dayOfMonth || 0) - ((day?.dayOfMonth || 0) - day.day)) === fullDaysInMonth;
const isLastDayOfMonth =
(day?.dayOfMonth || 0) - ((day?.dayOfMonth || 0) - day.day) ===
fullDaysInMonth;

const isToday = areDatesOnSameDay(day.date, today);
let inRange = false;
Expand Down Expand Up @@ -90,7 +91,8 @@ const DaySelector = () => {
if (
(isFirstDayOfMonth && selectedEndDay) ||
(isLastDayOfMonth && selectedStartDay) ||
dayjs(startDate).format('DDMMYYYY') === dayjs(endDate).format('DDMMYYYY')
dayjs(startDate).format('DDMMYYYY') ===
dayjs(endDate).format('DDMMYYYY')
) {
inRange = false;
}
Expand Down
2 changes: 1 addition & 1 deletion src/components/Header.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ const Header = ({ buttonPrevIcon, buttonNextIcon }: HeaderProps) => {
<View style={[styles.textContainer, theme?.headerTextContainerStyle]}>
<Text style={[styles.text, theme?.headerTextStyle]}>
{calendarView === 'year'
? `${years[0]} - ${years[years.length-1]}`
? `${years[0]} - ${years[years.length - 1]}`
: dayjs(currentDate).format('YYYY')}
</Text>
</View>
Expand Down
File renamed without changes.
17 changes: 6 additions & 11 deletions src/utils.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import dayjs from 'dayjs';
import type { DatePickerBaseProps, DateType, IDayObject } from './types';
import type { DateType, IDayObject } from './types';

export const CALENDAR_FORMAT = 'YYYY-MM-DD HH:mm';
export const DATE_FORMAT = 'YYYY-MM-DD';
Expand Down Expand Up @@ -189,8 +189,7 @@ export const getMonthDays = (
minDate: DateType,
maxDate: DateType,
firstDayOfWeek: number,
disabledDates: DateType[] | ((date: DateType) => boolean) | undefined,
firstDayOfWeek: number
disabledDates: DateType[] | ((date: DateType) => boolean) | undefined
): IDayObject[] => {
const date = getDate(datetime);
const {
Expand All @@ -211,8 +210,7 @@ export const getMonthDays = (
maxDate,
disabledDates,
false,
index + 1,
isDateDisabled
index + 1
);
})
: Array(prevMonthOffset).fill(null);
Expand All @@ -227,8 +225,7 @@ export const getMonthDays = (
maxDate,
disabledDates,
true,
prevMonthOffset + day,
isDateDisabled
prevMonthOffset + day
);
});

Expand All @@ -242,8 +239,7 @@ export const getMonthDays = (
maxDate,
disabledDates,
false,
daysInCurrentMonth + prevMonthOffset + day,
isDateDisabled
daysInCurrentMonth + prevMonthOffset + day
);
});

Expand All @@ -269,8 +265,7 @@ const generateDayObject = (
maxDate: DateType,
disabledDates: DateType[] | ((date: DateType) => boolean) | undefined,
isCurrentMonth: boolean,
dayOfMonth: number,
isDateDisabled?: DatePickerBaseProps['isDateDisabled']
dayOfMonth: number
) => {
return {
text: day.toString(),
Expand Down

0 comments on commit a9da6c8

Please sign in to comment.