UNPKG

chinese-days

Version:

中国节假日、调休日、工作日、24节气查询,农历阳历互转,支持 TS、CommonJS、UMD 模块化使用,提供 ics 日历格式,可供 Google Calendar、Apple Calendar、Microsoft Outlook 等客户端订阅。

175 lines (154 loc) 6.56 kB
declare type ConfigType = string | number | Date | Dayjs | null | undefined; declare class Dayjs { private _date; private static daysOfWeek; constructor(date?: ConfigType); toDate(): Date; isValid(): boolean; diff(date: string | number | Date | Dayjs | null | undefined, unit?: "day" | "month" | "year"): number; startOf(unit?: "year" | "month" | "day"): Dayjs; endOf(unit?: "year" | "month" | "day"): Dayjs; add(value: number, unit: "year" | "month" | "day"): Dayjs; subtract(value: number, unit: "year" | "month" | "day"): Dayjs; format(formatStr: string): string; year(): number; year(year: number): Dayjs; month(): number; month(month: number): Dayjs; date(): number; date(day: number): Dayjs; day(): number; day(day: number): Dayjs; isBefore(date: string | number | Date | Dayjs | null | undefined): boolean; isAfter(date: string | number | Date | Dayjs | null | undefined): boolean; isSame(date: string | number | Date | Dayjs | null | undefined, unit?: "year" | "month" | "day"): boolean; isBetween(startDate: string | number | Date | Dayjs | null | undefined, endDate: string | number | Date | Dayjs | null | undefined, unit?: "year" | "month" | "day"): boolean; } declare const _default: { getLunarDate: (date: ConfigType) => LunarDateDetail; getLunarDatesInRange: (startDate: ConfigType, endDate: ConfigType) => LunarDateDetail[]; getSolarDateFromLunar: (lunarDate: ConfigType) => { date: string; leapMonthDate?: string; }; default: { getLunarDate: (date: ConfigType) => LunarDateDetail; getLunarDatesInRange: (startDate: ConfigType, endDate: ConfigType) => LunarDateDetail[]; getSolarDateFromLunar: (lunarDate: ConfigType) => { date: string; leapMonthDate?: string; }; }; getSolarTermDate: (year: number, month: number, term: SolarTermKey) => string; getSolarTerms: (start?: ConfigType, end?: ConfigType) => SolarTerm_2.SolarTerm[]; getSolarTermsInRange: (start?: ConfigType, end?: ConfigType) => SolarTerm_2.SolarTerm[]; isHoliday: (date: ConfigType) => boolean; isWorkday: (date: ConfigType) => boolean; isInLieu: (date: ConfigType) => boolean; getDayDetail: (date: ConfigType) => { work: boolean; name: string; date: string; }; getHolidaysInRange: (start: ConfigType, end: ConfigType, includeWeekends?: boolean) => string[]; getWorkdaysInRange: (start: ConfigType, end: ConfigType, includeWeekends?: boolean) => string[]; findWorkday: (deltaDays?: number, date?: ConfigType) => string; }; export default _default; export declare const findWorkday: (deltaDays?: number, date?: ConfigType) => string; /** 获取工作日详情 */ export declare const getDayDetail: (date: ConfigType) => { work: boolean; name: string; date: string; }; /** 获取节假日 */ export declare const getHolidaysInRange: (start: ConfigType, end: ConfigType, includeWeekends?: boolean) => string[]; /** * 计算指定日期的农历元素 * @param date 指定日期 * @returns 农历信息 */ export declare const getLunarDate: (date: ConfigType) => LunarDateDetail; /** * 获取范围内所有日期的农历信息 * @param startDate 开始日期 * @param endDate 结束日期 * @returns 范围内所有日期的农历信息 */ export declare const getLunarDatesInRange: (startDate: ConfigType, endDate: ConfigType) => LunarDateDetail[]; /** * 根据阴历日期查询阳历日期 * @param lunarDate 农历日期 * @param isLeapMonth 是否闰月 * @returns 阳历日期 */ export declare const getSolarDateFromLunar: (lunarDate: ConfigType) => { date: string; leapMonthDate?: string; }; export declare const getSolarTermDate: (year: number, month: number, term: SolarTermKey) => string; /** * Get solar terms => 获取范围日期内的节气 开始的日期 * @param start 开始日期 * @param end 不传只查当天 * @returns Array of solar terms => 节气开始日数组 */ export declare const getSolarTerms: (start?: ConfigType, end?: ConfigType) => SolarTerm[]; /** * Get solar terms => 获取范围日期内的节气 * @param start 开始日期 * @param end 不传只查当天 * @returns Array of solar terms => 节气日数组 */ export declare const getSolarTermsInRange: (start?: ConfigType, end?: ConfigType) => SolarTerm[]; /** 获取工作日 */ export declare const getWorkdaysInRange: (start: ConfigType, end: ConfigType, includeWeekends?: boolean) => string[]; /** 是否节假日 */ export declare const isHoliday: (date: ConfigType) => boolean; /** 是否调休日 - 是节假日,但后续有需要补班 */ export declare const isInLieu: (date: ConfigType) => boolean; /** 是否工作日 */ export declare const isWorkday: (date: ConfigType) => boolean; declare interface LunarDateDetail { /** 阳历日期 */ date: string; /** 农历年份 */ lunarYear: number; /** 农历月份 */ lunarMon: number; /** 农历日期 */ lunarDay: number; /** 是否闰月 */ isLeap: boolean; /** 年柱,天干地支表示的年份 */ yearCyl: string; /** 月柱,天干地支表示的月份 */ monCyl: string; /** 日柱,天干地支表示的日期 */ dayCyl: string; /** 生肖 */ zodiac: string; /** 农历年份的中文写法 */ lunarYearCN: string; /** 农历月份的中文写法 */ lunarMonCN: string; /** 农历日期的中文写法 */ lunarDayCN: string; } export declare interface SolarTerm { date: string; term: SolarTermKey; name: string; index?: number; } declare namespace SolarTerm_2 { export { SolarTerm, getSolarTermDate, getSolarTerms, getSolarTermsInRange } } declare type SolarTermKey = "the_beginning_of_spring" | "rain_water" | "the_waking_of_insects" | "the_spring_equinox" | "pure_brightness" | "grain_rain" | "the_beginning_of_summer" | "lesser_fullness_of_grain" | "grain_in_beard" | "the_summer_solstice" | "lesser_heat" | "greater_heat" | "the_beginning_of_autumn" | "the_end_of_heat" | "white_dew" | "the_autumn_equinox" | "code_dew" | "frost_descent" | "the_beginning_of_winter" | "lesser_snow" | "greater_snow" | "the_winter_solstice" | "lesser_cold" | "greater_cold"; export { }