lunar-info
TypeScript icon, indicating that this package has built-in type declarations

1.0.0 • Public • Published

lunar-info

This package provides a convenient way to retrieve lunar information for specific dates and access holiday information.

Installation

npm install lunar-info

Usage

import {getLunar, getHolidaysThisYear, getLunarHolidaysThisYear} from 'lunar-info';

// Example 1: Get Lunar Information for a Date
const lunarInfo = getLunar(2018, 12, 1);
console.log(lunarInfo);

// Example 2: Get Holidays for the Current Year [1900,2099]
const holidays = getHolidaysThisYear(new Date().getFullYear());
console.log(holidays);

// Example 3: Get Lunar Holidays for the 2008 Year [1900,2099] 2008 is lunar year
const lunarHolidays = getLunarHolidaysThisYear(2008);
console.log(lunarHolidays);

API Reference

getLunar(year: number, month: number, day: number): object

Get lunar information for a specific date.

Parameters:

  • year: A number representing the year of the desired date. Must be in the range from 1900 to 2099.
  • month: A number representing the month of the desired date. Must be in the range from 1 to 12.
  • day: A number representing the day of the desired date. The valid range depends on the specific lunar month and year.

Returns: An object containing the lunar information for the provided date, including:

  • yang_y: number; // 阳历年 【2023】
  • yang_m: number; // 阳历月 【5】
  • yang_d: number; // 阳历日 【1】
  • yang_yyyymmdd: string; // 阳历 【20230501】
  • yin_y: number; // 阴历年 【2023】
  • yin_m: number; // 阴历月 【3】
  • yin_d: number; // 阴历日 【12】
  • run_yin_m: number; // 本年闰月的月份 【0】 0 代表当年无闰月 1-12 为当年的闰月阴历月
  • yin_m_name: string; // 阴历月份对应的汉字 【三月】
  • yin_d_name: string; // 阴历日期对应的汉字 【十二】
  • yin_gz_y: string; // 阴历 干支年 【癸卯】
  • yin_gz_m: string; // 阴历 干支月 【丙辰】
  • yin_gz_d: string; // 阴历 干支日 【己未】
  • shu: string; // 阴历 属 【兔】
  • week: string; // 星期 汉字 【星期一】
  • week_index: number; // 星期 数字 【1】 0 表示星期日,1 表示星期一,以此类推
  • week_number: number; // 当前是第几周 【22】
  • xing_zuo: string; // 星座 【金牛】
  • yin_jie_ri: string; // 阴历节日
  • yang_jie_ri: string; // 阳历节日 【劳动节】
  • jie_qi: string; // 24 节气 【小雪】 | ""
  • compute_jie_ri: string; // 计算的节日 【父亲节】 | ‘’
  • y: string; // j: 【-】
  • j: string; // y: 【诸事不宜】
  • ... (other relevant lunar information)

getHolidaysThisYear(year: number): object

Parameters:

  • year: A number representing the year of the desired date. Must be in the range from 1900 to 2099.

Returns:

  • 0101: '元旦';
  • 0214: '情人节';
  • 0308: '妇女节';
  • 0312: '植树节';
  • 0401: '愚人节';
  • 0501: '劳动节';
  • 0504: '青年节';
  • 0601: '儿童节';
  • 0701: '建党日';
  • 0801: '建军节';
  • 0910: '教师节';
  • 1001: '国庆节';
  • 1031: '万圣夜';
  • 1101: '万圣节';
  • 1111: '光棍节';
  • 1224: '平安夜';
  • 1225: '圣诞节';
  • '母亲节'
  • '父亲节'
  • '感恩节'

getLunarHolidaysThisYear(year: number): object

Parameters:

  • year: A number representing the year of the desired date. Must be in the range from 1900 to 2099.

Returns:

  • 0101: '春节';
  • 0115: '元宵节';
  • 0202: '龙抬头';
  • 0303: '上巳节';
  • 0505: '端午节';
  • 0624: '火把节';
  • 0707: '七夕';
  • 0715: '中元节';
  • 0815: '中秋节';
  • 0909: '重阳节';
  • 1001: '寒衣节';
  • 1015: '下元节';
  • 1208: '腊八节';
  • 1223: '北小年';
  • 1224: '南小年';
  • '除夕'
  • '清明'

Package Sidebar

Install

npm i lunar-info

Weekly Downloads

7

Version

1.0.0

License

MIT

Unpacked Size

540 kB

Total Files

19

Last publish

Collaborators

  • onsong