fortel-solar-term
v1.0.0
Published
[![npm version](https://img.shields.io/npm/v/fortel-solar-term.svg)](https://www.npmjs.com/package/fortel-solar-term) [![node](https://img.shields.io/node/v/fortel-solar-term.svg)](https://www.npmjs.com/package/fortel-solar-term) [![Build](https://travi
Downloads
6
Readme
fortel-solar-term
This node.js module is a library for some Chinese Astrology 24 terms.(24節氣) 這是一個關於24節氣的nodejs library. 能在時間與節氣年份月份之間換算。
Project page
Wiki pages for Chinese Astrology:
Install
$ npm install --save fortel-solar-term
API & Samples
remarks:
- 年份的定義為該年的立春直至下年的立春
- 月份的定義為以節氣計算的月份 (e.g: 1月 = 立春直至驚蟄之間)
- 換算會有約在5分鍾以內的誤差
估算該年月份的開始及完結時間
API:
new TermYearMonth(year, month).getRange();
input:
- year: 以節氣計的年份
- month: 節氣月份
output:
- format: { start: xxx, end: xxx }
- start: 節氣月份的開始時間 (moment object)
- end: 節氣月份的開始時間 (moment object)
remarks:
- 這個年份的定義為該年的立春直至下年的立春
- 這個月份的定義為以節氣計算的月份 (e.g: 1月 = 立春直至驚蟄之間)
- Expected error within 5 min
code:
const fortelSolarTerm = require('fortel-solar-term');
let { TermDatetime, TermYearMonth } = fortelSolarTerm;
// 2019年1月
let {start, end} = new TermYearMonth(2019, 1).getRange();
console.log(`start: ${start.toLocaleString()}`);
console.log(`end: ${end.toLocaleString()}`);
output:
start: Mon Feb 04 2019 11:11:22 GMT+0800
end: Wed Mar 06 2019 05:06:35 GMT+0800
估算某時間所屬的節氣月份
API:
new TermDatetime(datetime).getYearTermMonth();
input:
- datetime: moment object or moment object constructor parameter (single parameter)
output:
- format: { termYear: 2019, termMonth: 1 }
- termYear: 以節氣計算所屬的年份
- termMonth: 以節氣計算所屬的月份
code:
const fortelSolarTerm = require('fortel-solar-term');
const moment = require('moment');
let { TermDatetime, TermYearMonth } = fortelSolarTerm;
// 2019年1月
console.log(new TermDatetime(moment.parseZone("2019-02-04T11:00:00+08:00")).getYearTermMonth());
output:
TermYearMonth { termYear: 2018, termMonth: 12 }
Author Contact
- Eric Yu: [email protected]