企业🤖AI智能体构建引擎,智能编排和调试,一键部署,支持知识库和私有化部署方案 广告
阴历的实例化有以下几种方式: 1. Lunar.fromYmd(lunarYear, lunarMonth, lunarDay) > 指定`阴历年(数字)`、`阴历月(数字)`、`阴历日(数字)`生成阴历对象。注意月份为1到12,闰月为负,即闰2月=-2。 2. Lunar.fromYmdHms(lunarYear, lunarMonth, lunarDay, hour, minute, second) > 指定`阴历年(数字)`、`阴历月(数字)`、`阴历日(数字)`、`阳历小时(数字)`、`阳历分钟(数字)`、`阳历秒钟(数字)`生成阴历对象。注意月份为1到12,闰月为负,即闰2月=-2。 3. Lunar.fromDate(date) > 指定`阳历日期(Date)`生成阴历对象 ### 示例代码 ``` let d = Lunar.fromYmd(1986, 4, 21); console.log(d.toFullString()); d = Lunar.fromDate(new Date()); console.log(d.toFullString()); d = Lunar.fromYmdHms(1986, 4, 21, 20, 5, 0); // 时辰 console.log(d.getTimeZhi()+'时'); ```