v1.6.4 中元节改为农历七月十五;修复Solar的nextMonth超期问题。
This commit is contained in:
@@ -134,3 +134,18 @@ test('25', () => {
|
||||
})
|
||||
expect(timeList).toStrictEqual(['1959-12-17 16:00:00']);
|
||||
});
|
||||
|
||||
test('26', () => {
|
||||
const solar = Solar.fromYmd(2023, 8, 31);
|
||||
expect(solar.nextMonth(2).toYmd()).toBe('2023-10-31');
|
||||
});
|
||||
|
||||
test('27', () => {
|
||||
const solar = Solar.fromYmd(2023, 8, 31);
|
||||
expect(solar.nextYear(2).toYmd()).toBe('2025-08-31');
|
||||
});
|
||||
|
||||
test('28', () => {
|
||||
const solar = Solar.fromYmd(2023, 8, 31);
|
||||
expect(solar.nextMonth(6).toYmd()).toBe('2024-02-29');
|
||||
});
|
||||
|
||||
27
lunar.js
27
lunar.js
@@ -350,19 +350,17 @@
|
||||
var y = this._p.year + years;
|
||||
var m = this._p.month;
|
||||
var d = this._p.day;
|
||||
// 2月处理
|
||||
if (2 === m) {
|
||||
if (1582 === y && 10 === m) {
|
||||
if (d > 4 && d < 15) {
|
||||
d += 10;
|
||||
}
|
||||
} else if (2 === m) {
|
||||
if (d > 28) {
|
||||
if (!SolarUtil.isLeapYear(y)) {
|
||||
d = 28;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (1582 === y && 10 === m) {
|
||||
if (d > 4 && d < 15) {
|
||||
d += 10;
|
||||
}
|
||||
}
|
||||
return _fromYmdHms(y, m, d, this._p.hour, this._p.minute, this._p.second);
|
||||
},
|
||||
nextMonth:function(months){
|
||||
@@ -375,18 +373,15 @@
|
||||
var y = month.getYear();
|
||||
var m = month.getMonth();
|
||||
var d = this._p.day;
|
||||
// 2月处理
|
||||
if (2 === m) {
|
||||
if (d > 28) {
|
||||
if (!SolarUtil.isLeapYear(y)) {
|
||||
d = 28;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (1582 === y && 10 === m) {
|
||||
if (d > 4 && d < 15) {
|
||||
d += 10;
|
||||
}
|
||||
} else {
|
||||
var maxDay = SolarUtil.getDaysOfMonth(y, m);
|
||||
if (d > maxDay) {
|
||||
d = maxDay;
|
||||
}
|
||||
}
|
||||
return _fromYmdHms(y, m, d, this._p.hour, this._p.minute, this._p.second);
|
||||
},
|
||||
@@ -4536,7 +4531,7 @@
|
||||
'9-9':'{jr.chongYang}',
|
||||
'12-8':'{jr.laBa}'
|
||||
},
|
||||
OTHER_FESTIVAL:{'1-4':['接神日'],'1-5':['隔开日'],'1-7':['人日'],'1-8':['谷日','顺星节'],'1-9':['天日'],'1-10':['地日'],'1-20':['天穿节'],'1-25':['填仓节'],'1-30':['正月晦'],'2-1':['中和节'],'2-2':['社日节'],'3-3':['上巳节'],'5-20':['分龙节'],'5-25':['会龙节'],'6-6':['天贶节'],'6-24':['观莲节'],'6-25':['五谷母节'],'7-14':['中元节'],'7-22':['财神节'],'7-29':['地藏节'],'8-1':['天灸日'],'10-1':['寒衣节'],'10-10':['十成节'],'10-15':['下元节'],'12-7':['驱傩日'],'12-16':['尾牙'],'12-24':['祭灶日']},
|
||||
OTHER_FESTIVAL:{'1-4':['接神日'],'1-5':['隔开日'],'1-7':['人日'],'1-8':['谷日','顺星节'],'1-9':['天日'],'1-10':['地日'],'1-20':['天穿节'],'1-25':['填仓节'],'1-30':['正月晦'],'2-1':['中和节'],'2-2':['社日节'],'3-3':['上巳节'],'5-20':['分龙节'],'5-25':['会龙节'],'6-6':['天贶节'],'6-24':['观莲节'],'6-25':['五谷母节'],'7-15':['中元节'],'7-22':['财神节'],'7-29':['地藏节'],'8-1':['天灸日'],'10-1':['寒衣节'],'10-10':['十成节'],'10-15':['下元节'],'12-7':['驱傩日'],'12-16':['尾牙'],'12-24':['祭灶日']},
|
||||
CHONG:['{dz.wu}', '{dz.wei}', '{dz.shen}', '{dz.you}', '{dz.xu}', '{dz.hai}', '{dz.zi}', '{dz.chou}', '{dz.yin}', '{dz.mao}', '{dz.chen}', '{dz.si}'],
|
||||
CHONG_GAN:['{tg.wu}', '{tg.ji}', '{tg.geng}', '{tg.xin}', '{tg.ren}', '{tg.gui}', '{tg.jia}', '{tg.yi}', '{tg.bing}', '{tg.ding}'],
|
||||
CHONG_GAN_TIE:['{tg.ji}', '{tg.wu}', '{tg.xin}', '{tg.geng}', '{tg.gui}', '{tg.ren}', '{tg.yi}', '{tg.jia}', '{tg.ding}', '{tg.bing}'],
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "lunar-javascript",
|
||||
"version": "1.6.3",
|
||||
"version": "1.6.4",
|
||||
"description": "lunar is a calendar library for Solar and Chinese Lunar.",
|
||||
"main": "index.js",
|
||||
"scripts": {
|
||||
|
||||
Reference in New Issue
Block a user