npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

@marchingy/lunar

v0.1.1

Published

Chinese calendar with the 24 solar terms.

Downloads

38

Readme

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. 计算二十四节气