@alifd/meet-react
Version:
Fusion Mobile React UI System Component
52 lines (51 loc) • 2.2 kB
TypeScript
import dayjs from 'dayjs';
type IntervalMode = '()' | '[]' | '[)' | '(]';
export type AvailableDate = Date | string | dayjs.Dayjs | number;
export declare function formatDate(d: AvailableDate, format: string, invalidStr?: string): string;
export declare function isValidDate(obj?: Date): obj is Date;
export declare function toValidDate(from?: AvailableDate, defaultDate?: Date): Date;
export declare function toDate(from?: AvailableDate): Date;
export declare function isBetween(date: dayjs.ConfigType, startDate: dayjs.ConfigType, endDate: dayjs.ConfigType, unit?: dayjs.OpUnitType, intervalMode?: IntervalMode): boolean;
export declare function toDay(from: AvailableDate): dayjs.Dayjs;
export declare function cloneDate(d: Date): Date;
type DateNumType = 'y' | 'm' | 'd' | 'h' | 'i' | 's';
export declare function getDateNum(type: DateNumType, d: Date): number;
export declare function isTypeSame(type: DateNumType, d1: Date, d2: Date): boolean;
export declare enum RANGE_CHECK_RESULT {
IN_RANGE = 0,
SMALL_THAN_HOUR = 1,
BIGGER_THAN_HOUR = 2,
SMALL_THAN_MIN = 3,
BIGGER_THAN_MIN = 4,
SMALL_THAN_SEC = 5,
BIGGER_THAN_SEC = 6,
SMALL_THAN_YEAR = 7,
BIGGER_THAN_YEAR = 8,
SMALL_THAN_MONTH = 9,
BIGGER_THAN_MONTH = 10,
SMALL_THAN_DAY = 11,
BIGGER_THAN_DAY = 12
}
export interface TimeOptions {
hasHour?: boolean;
hasMinute?: boolean;
hasSecond?: boolean;
}
export interface DateCheckOptions {
date?: {
hasYear: boolean;
hasMonth: boolean;
hasDay: boolean;
};
time?: TimeOptions;
}
export declare function checkDateRange(d: Date, options: DateCheckOptions, validRange?: [Date, Date]): RANGE_CHECK_RESULT;
export declare function getRangeDate(d: Date, options: DateCheckOptions, validRange?: [Date, Date]): Date;
interface TimeExtraOptions {
hourStep?: number;
minuteStep?: number;
secondStep?: number;
}
export declare function getNearestDate(options: TimeOptions, extra: TimeExtraOptions, d: Date, calcType: 'auto' | 'plus' | 'minus'): Date;
export declare function getRealRange(options: TimeOptions, extra: TimeExtraOptions, validRange?: [Date, Date]): [Date, Date] | undefined;
export {};