Git Product home page Git Product logo

lunar's Introduction

Lunar (Chinese calendar)


The standard mentioned below which means GB/T 33661-2017 - Calculation and promulgation of the Chinese calendar. The lunar mentioned below which means this library.


All algorithms in the package are according to the standard to be implemented. And used ephemeris to calculate sun ecliptic longitude and moon ecliptic longitude.

Some earlier dates might not are satisfied with the outputs of the lunar, the lunar use astronomy algorithms to reach high-precision results. Like 8/25/1919 and 1/25/1944, these dates were the first dates of the lunar months in the real history, but they are not new moons according to astronomy algorithms. and 8/26/1919 and 1/26/1944 were new moons, they should were the first dates.


Including:

  1. Calculate the solar term of a day, solar terms of year, 24 solar terms;
  2. Calculate month and day of Chinese calendar, and leap months;
  3. Calculate sexagesimal(celestial stem with terrestrial branch) of day, month and year;
  4. Calculate zodiac of year.


API

class ChineseDate(inherit native Date)

Methods

  • getLunarYear(): OLunarYear
  • getLunarMonth(): OLunarMonth
  • getLunarDay(): OLunarDay
  • toChineseString(): string | A date locale string in zh-CN language in PRC time zone
  • toLunarString(): string | example: 农历壬寅年九月甲申日

inteface OLunarYear

  • sexagesimal(): string | example: 壬寅
  • zodiac(): string | example: 虎
  • toString(): string | example: 壬寅年 虎年

inteface OLunarMonth

  • capital(): string | example: 九
  • isLeap(): boolean
  • sexagesimal(): string | example: 己酉
  • toString(): string | example: 己酉月 九月

inteface OLunarDay

  • capital(): string | example: 初十
  • sexagesimal(): string | example: 甲申
  • toString(): string | example: 癸亥日 初九


Calendar tools

  • countDaysOnYear(year: number): number
  • isNewMoon(date: Date): boolean
  • countNewMoons(fromDate: Date, toDate: Date): Array
  • getWinterSolstice(year: number): Date
  • isMissingMidTermMonth(date: Date): boolean
  • isLeapMonth(date: Date): boolean


Solar terms

class SolarTerm

Constructor

constructor(public readonly order: number, public readonly longitude: number, public label: string)

The parameter "order" must be an integer from 1 to 24. The parameter "longitude" must be an integer from 0 to 360, and must be in multiples of 15.

Properties
  • date: ChineseDate | undefined
  • label: string
  • readonly order: number
  • readonly longitude: number
Methods
  • isMidTerm(): boolean
  • toString(): string
  • static create(index: number[, lang: Array]): SolarTerm | index is an integer from 1 to 24.

create24SolarTerms([lang: Array]): Map<number, SolarTerm>

getTermOnDay(date: Date[, coordinate: GeoJSON.Position]): SolarTerm | null

countSolarTerms(fromDate: Date, toDate: Date): Array

getTermsOnYear(year: number[, coordinate: GeoJSON.Position]): Array


calcSunEclipticLongitude(time: Date[, coordinate: GeoJSON.Position]): number

Calculate sun ecliptic longitude at the time.

calcMoonEclipticLongitude(time: Date[, coordinate: GeoJSON.Position]): number

Calculate moon ecliptic longitude at the time.

calcDiffOfSunAndMoon(time: Date[, coordinate: GeoJSON.Position]): number

Calculate different value between sun ecliptic longitude at the time and moon ecliptic longitude at the time.


Note: the default coordinate parameter is [120, 0].


References

  1. GB/T 33661-2017 - Calculation and promulgation of the Chinese calendar

  2. Leap months

  3. 计算二十四节气

lunar's People

Stargazers

 avatar

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.