Coder Social home page Coder Social logo

chinese_lunar_calendar's Introduction

安装

npm install --save chinese-lunar-calendar

使用

import { getLunar } from 'chinese-lunar-calendar'

// 传入1991年2月1日
console.log(getLunar(1991, 2, 1)); 
/*输出
{ 
  lunarMonth: 12,   //农历月份
  lunarDate: 17,    //农历日期
  isLeap: false,    //是否闰月
  solarTerm: null,  //节气,null代表没有
  lunarYear: '庚午年', //农历年份,年以正月初一开始
  zodiac: '马',     //生肖,生肖以正月初一开始
  dateStr: '腊月十七' //农历中文
}
*/

dist/chinese_lunar_calendar.min.js 是打包好的库,可用于浏览器可以直接引入,简单例子

原理

这个库是通过抓取香港天文台 (http://data.weather.gov.hk/gts/time/calendar/text/T2019c.txt) 的数据, 把每年闰月月份和每月的大小保存下来编码压缩,先解压生成数据表,再通过查表算出农历日期和节气

注意!!

某些库和iPhone日历上2057-9-28是八月三十、2097-8-7是六月三十, 这里的数据和win10日历上2057-9-28是九月初一、2097-8-7是七月初一

chinese_lunar_calendar's People

Contributors

moonball avatar linlifengx avatar

Stargazers

Tmax avatar plain avatar  avatar vico avatar

Watchers

James Cloos avatar

chinese_lunar_calendar's Issues

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.