# idea-date-utils **Repository Path**: althenwaysatan/idea-date-utils ## Basic Information - **Project Name**: idea-date-utils - **Description**: No description available - **Primary Language**: Unknown - **License**: MIT - **Default Branch**: master - **Homepage**: None - **GVP Project**: No ## Statistics - **Stars**: 0 - **Forks**: 0 - **Created**: 2025-05-08 - **Last Updated**: 2025-05-27 ## Categories & Tags **Categories**: Uncategorized **Tags**: None ## README # 便单日期工具 bdDate ## 约束限制: - 本示例仅支持标准系统上运行; - 本示例支持API version 12及以上版本SDK; - 本示例需要使用DevEco Studio 5.0 Release版本进行编译运行; ## 安装教程: 1. 代码克隆到本地,在DevEco Studio 工具栏中选择:文件-新建-导入-导入模块; 2. 在需要调用bdDate的模块文件**oh-package.json5**中的**dependencies**字段新增对应依赖。 ## 部分功能详情: ``` /** * 传入阳历年月日获得详细的公历、农历object信息 <=>JSON * @param y solar year * @param m solar month * @param d solar day * @return JSON object * @eg:console.log(calendar.solar2lunar(1987,11,01)); */ solar2lunar(y: number, m: number, d: number): lunarObject | undefined /** * 传入农历年月日以及传入的月份是否闰月获得详细的公历、农历object信息 <=>JSON * @param y lunar year * @param m lunar month * @param d lunar day * @param isLeapMonth lunar month is leap or not.[如果是农历闰月第四个参数赋值true即可] * @return JSON object * @eg:console.log(calendar.lunar2solar(1987,9,10)); */ export function lunar2solar(y: number, m: number, d: number, isLeapMonth: boolean = false) /** * 获取农历完整描述 * @param date * @returns */ chineseCalendar.getChineseFullDescription(date: Date): string /** * 获取日期描述 * @param date * @returns */ dateTool.getDateDescription(date: Date): string /** * 获取间隔日描述 * @param formDate * @param toDate * @returns */ dateTool.getDescriptionFromTo(formDate: Date, toDate: Date): string /** * 根据 ISO 8601 标准来计算输入日期是该年的第几周 * @param date * @returns */ dateTool.getISOWeekNumber(date: Date): number /** * 获取日期是否是节假日 * @param date * @returns 是否是节假日 */ isHoliday(date: Date): boolean ``` ## 快速开始 ``` import { solar2lunar, isHoliday } from 'bdDate'; // 节假日检测示例 const nationalDay = new Date(2025, 9, 1); if (isHoliday(nationalDay)) { console.log("国庆假期开始!"); } // 复杂日期转换 const weddingDate = solar2lunar(2025, 10, 6); console.log(`农历日期:${weddingDate?.lMonth}月${weddingDate?.lYear}`); ``` ## 注意事项 - 农历数据范围:1900年1月-2100年12月 - 节假日数据包含中国法定节假日(2024-2025年) - 闰月参数仅在农历转换时生效