微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

calendar-converter

程序名称:calendar-converter

授权协议: MIT

操作系统: 跨平台

开发语言: JavaScript

calendar-converter 介绍

calendar-converter 是 JavaScript 版本的公历和农历的互转库。

示例代码

    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: "日"                // 周几
     }

calendar-converter 官网

https://github.com/StuPig/calendar-converter

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 [email protected] 举报,一经查实,本站将立刻删除。

相关推荐