Code Monkey home page Code Monkey logo

chinese-lunar's Introduction

命理基本的查詢

npm npm Build Status Coverage Status

只要輸入年月日,就可以轉換成年柱,月柱,日柱,時柱,農曆月,農曆日,節氣,星期,生肖,星座的資訊

近期會頻繁的更新,但整體的架構未來會劃分為三個 BasicLunarAdvancedLunarApplicationLunar 可以依照你的需求去使用唷。 小提醒:Application 包含前面兩者的功能,如果使用 Advance 就無法使用 Application 的功能。

預計今年底能推出正式的一版1.0.0,接下來把每一個功能的說明詳細做個介紹以及範例使用。

ChangeLog

  • 2019/10/16 0.5.0版本提供了.getJson()的方法讓大家可以方便取得所有資訊。
  • 2019/10/17 0.6.0版本提供了生肖的查詢。
  • 2019/10/18 0.6.2版本提供了十神的查詢,新增在ApplicationLunar,所以要使用此方法需 new ApplicationLunar()。
  • 2019/10/19 0.6.4版本提供了此年的閏月是哪一個月份的查詢,新增在AdvancedLunar
  • 2019/10/21 0.7.0版本提供了更長的範圍,從 1956 到 1900 補齊囉~接下來應該就會再往 2050 年之後邁進
  • 2019/10/23 0.8.0版本提供了星座,可以從.getJson()constellationproperty 拿到
  • 2019/10/23 0.8.1版本修復十神,十神需提供使用者出生的年柱做搭配
  • 2019/10/24 0.9.0版本提供了此年的農曆中每個月有多少天getLunarPerMonthHasDays,這裡可以搭配0.6.4版推出的閏月是哪一天來應用。

使用範例

npm i @tony801015/chinese-lunar -S
const {
  AdvancedLunar,
  AdvancedLunar,
  ApplicationLunar
} = require("@tony801015/chinese-lunar");

/**
 * Input
 * @params {string} 年
 * @params {string} 月
 * @params {string} 日
 * @parasm {string} 使用者出生的年柱(天干地支)
 */
const Lunar = new ApplicationLunar("2020", "03", "05", "壬子");

// Json format
console.log(Lunar.getJson());
// {
//   year: '2020',
//   month: '03',
//   day: '05',
//   solarTerms: '驚蟄',
//   lunarMonth: '二月',
//   lunarDay: '十二',
//   chineseYear: '庚子',
//   chineseMonth: '己卯',
//   chineseDay: '丁未',
//   chineseTime: [ '庚子', '辛丑', '壬寅', '癸卯', '甲辰', '乙巳', '丙午', '丁未', '戊申', '己酉', '庚戌', '辛亥' ],
//   week: '4',
//   animal: '鼠',
//   constellation: '雙魚座',
//   chineseTimeTenGod: [ 'ㄗ', '印', '比', '劫', '食', '傷', '才', '財', '殺', '官', 'ㄗ', '印' ],
//   dengGui: '亥丑',
//   leapMonth: 4
// }

// BasicLunar
console.log(Lunar.year, Lunar.month, Lunar.day); // 2020 03 05
console.log(`${Lunar.chineseYear}/${Lunar.chineseMonth}/${Lunar.chineseDay}`); // 庚子/己卯/丁未
console.log(`${Lunar.lunarMonth}/${Lunar.lunarDay}`); // 二月/十二
console.log(`${Lunar.solarTerms}`); // 驚蟄
console.log(`${Lunar.week}`); // 4
console.log(`${Lunar.chineseTime}`); // 庚子,辛丑,壬寅,癸卯,甲辰,乙巳,丙午,丁未,戊申,己酉,庚戌,辛亥
console.log(`${Lunar.animal}`); // 鼠

// AdvancedLunar 時間的十神, 登貴
console.log(`${Lunar.chineseTimeTenGod}`); // 財,才,官,殺,印,ㄗ,劫,比,傷,食,財,才
console.log(`${Lunar.dengGui}`); // 亥丑
console.log(Lunar.leapMonth); // 4
console.log(Lunar.lunarPerMonthHasDays); // [ '29', '30', '30', '30', '29', '30', '29', '29', '30', '29', '30', '29', '30' ]

// ApplicationLunar
console.log(Lunar.getTenGod("壬", Lunar.chineseDay.split("")[0])); // 財

分享

設定檔 config.js 裡面有一些整理過的資訊,希望可以幫助到大家對於命理上的研究。歡迎大家找我討論~

注意事項

  • 目前計算的時間以 1900 年開始至 2050 年,1900 以前的都無法計算。

未來規劃

未來會再增加

  • 星座 BasicLunar 2019/10/23 完成 0.8.0
  • 此年的閏月是幾月 AdvancedLunar 2019/10/19 完成 0.6.4
  • 此年的農曆中每個月有多少天 AdvancedLunar 2019/10/24 完成 0.9.0
  • 農曆日期的差距有幾天 ApplicationLunar
  • 十神的查詢 ApplicationLunar 2019/10/17 完成 0.6.2
  • 提供時間的輸入,在八字裡面其實就是把,,,轉成年柱,月柱,日柱,時柱,因此要把八字更精準推出命理相關的數據,需要的協助囉。

chinese-lunar's People

Contributors

pentium-tony avatar tony801015 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.