2.1.4 • Published 3 years ago

calendar-converter v2.1.4

Weekly downloads
-
License
ISC
Repository
-
Last release
3 years ago

calendar-converter

TODO: 农历转公历、公历转农历

Usage

//commonJs
const calendarConverter = require('calendar-converter');
//ESModule
import CalendarConverter from 'calendar-converter'

// 农历转公历
 var cc  =new CalendarConverter;
 cc.lunar2solar(new Date(2011, 0, 3)); ---> 2010,11,29
//公历转农历
 cc.solar2lunar(new Date(2010, 10, 29)); ----> 2011, 1, 3
 
//农历转公历时,如果那一月是那一年的闰月,则需额外传一个参数,才能得到正确的公历日期
cc.solar2lunar(new Date(2012, 4, 27)); // 2012年4月初7, 其中 isLeap为true,表示为闰四月
cc.lunar2solar(new Date(2012, 3, 7)) //得到错误时间:2012, 4, 27
cc.lunar2solar(new Date(2012, 3, 7), true)//正确: 2012, 5, 27

result

{
    cDay: "戊戌",
    cMonth: "丁未",
    cYear: "壬辰",
    isLeap: false,
    lDay: 18,
    lMonth: 6,
    lYear: 2012,
    lunarDay: "十八",
    lunarFestival: "",
    lunarMonth: "六",
    lunarYear: "龙",
    sDay: 5,
    sMonth: 8,
    sYear: 2012,
    solarFestival: "",// 节日
    solarTerms: "",            // 节气
    week: "日"                // 周几
 }

注意

日期传入方式示例
2021-9-27 =》 new Date(2021,8,27)
2.1.4

3 years ago

2.1.3

3 years ago

2.1.2

3 years ago

2.1.1

3 years ago