Skip to content

Commit

Permalink
refactor(ui): use false instead of null in dOrder
Browse files Browse the repository at this point in the history
  • Loading branch information
xiejay97 committed Nov 23, 2022
1 parent d25d315 commit 16a7c83
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 4 deletions.
4 changes: 2 additions & 2 deletions packages/ui/src/components/_date-input/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,14 +34,14 @@ export function deepCompareDate(a: Date | null | [Date, Date], b: Date | null |
return false;
}

export function orderDate(date: [Date, Date], order: 'ascend' | 'descend' | null, unit?: OpUnitType): boolean {
export function orderDate(date: [Date, Date], order: 'ascend' | 'descend' | false, unit?: OpUnitType): boolean {
if ((order === 'ascend' && dayjs(date[0]).isAfter(date[1], unit)) || (order === 'descend' && dayjs(date[0]).isBefore(date[1], unit))) {
return true;
}
return false;
}

export function orderTime(time: [Date, Date], order: 'ascend' | 'descend' | null): boolean {
export function orderTime(time: [Date, Date], order: 'ascend' | 'descend' | false): boolean {
const t1 = dayjs(time[0]).set('year', 2000).set('month', 0).set('date', 1);
const t2 = dayjs(time[1]).set('year', 2000).set('month', 0).set('date', 1);

Expand Down
2 changes: 1 addition & 1 deletion packages/ui/src/components/date-picker/DatePicker.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ export interface DDatePickerProps extends Omit<React.HTMLAttributes<HTMLDivEleme
dFormat?: string;
dVisible?: boolean;
dPlacement?: 'top' | 'top-left' | 'top-right' | 'bottom' | 'bottom-left' | 'bottom-right';
dOrder?: 'ascend' | 'descend' | null;
dOrder?: 'ascend' | 'descend' | false;
dPlaceholder?: string | [string?, string?];
dRange?: boolean;
dSize?: DSize;
Expand Down
2 changes: 1 addition & 1 deletion packages/ui/src/components/time-picker/TimePicker.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ export interface DTimePickerProps extends Omit<React.HTMLAttributes<HTMLDivEleme
dFormat?: string;
dVisible?: boolean;
dPlacement?: 'top' | 'top-left' | 'top-right' | 'bottom' | 'bottom-left' | 'bottom-right';
dOrder?: 'ascend' | 'descend' | null;
dOrder?: 'ascend' | 'descend' | false;
dPlaceholder?: string | [string?, string?];
dRange?: boolean;
dSize?: DSize;
Expand Down

0 comments on commit 16a7c83

Please sign in to comment.