# 获取某年的第几个农历节气信息

```/**
* 获取某年的第几个农历节气信息
* ========================================================================
* 这种推算的方法是建立在地球回归年的长度是固定365.2422天、节气的间隔是绝对固定的、
* 朔望月长度是平均的29.5305天等假设之上的，由于天体运动的互相影响，这种假设不是绝对
* 成立的，因此这种推算方法的误差较大。
* ========================================================================
* @param {Number} year - 年份信息
* @param {Number} i - 第几个节气（0 ~ 23）
* @returns {{value: string, text: *}}
*/
const getLunarSolarTerm = (year, i) => {
// 二十四个节气就是黄道上的24各点，由于地球运动受其它天体的影响，
// 导致这些节气在每年的时间是不固定的，但是这些节气之间的间隔时间
// 基本上可以看作是固定的，下表就是二十四节气的时间间隔表
const TERMS = [
{
text: '小寒',
diff: 0
},
{
text: '大寒',
diff: 1272494.40
},
{
text: '立春',
diff: 2548020.60
},
{
text: '雨水',
diff: 3830143.80
},
{
text: '惊蛰',
diff: 5120226.60
},
{
text: '春分',
diff: 6420865.80
},
{
text: '清明',
diff: 7732018.80
},
{
text: '谷雨',
diff: 9055272.60
},
{
text: '立夏',
diff: 10388958.00
},
{
text: '小满',
diff: 11733065.40
},
{
text: '芒种',
diff: 13084292.40
},
{
text: '夏至',
diff: 14441592.00
},
{
text: '小暑',
diff: 15800560.80
},
{
text: '大暑',
diff: 17159347.20
},
{
text: '立秋',
diff: 18513766.20
},
{
text: '处暑',
diff: 19862002.20
},
{
text: '白露',
diff: 21201005.40
},
{
text: '秋分',
diff: 22529659.80
},
{
text: '寒露',
diff: 23846845.20
},
{
text: '霜降',
diff: 25152606.00
},
{
text: '立冬',
diff: 26447687.40
},
{
text: '小雪',
diff: 27733451.40
},
{
text: '大雪',
diff: 29011921.20
},
{
text: '冬至',
diff: 30285477.60
}
]
// BASE 是 2001年 小寒时刻：1月5日 14:38:00，儒略日数：2451914.5
// 该数据是南京紫金山天文台提供的数据
const BASE = 2451914.5
let JD = (365.24219878 * (year - 2001) + TERMS[i].diff / 86400.0) + BASE
let date = convertJD2CE(JD)

return {
value: date.value,
text: TERMS[i].text
}
}```
##### Clone this wiki locally
You can’t perform that action at this time.