Skip to content

Commit

Permalink
v1.6.4 中元节改为农历七月十五;修复Solar的nextMonth超期问题。
Browse files Browse the repository at this point in the history
  • Loading branch information
6tail committed Sep 1, 2023
1 parent 0863bb6 commit 2c7fa90
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 17 deletions.
15 changes: 15 additions & 0 deletions __tests__/Solar.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 changes: 11 additions & 16 deletions lunar.js
Original file line number Diff line number Diff line change
Expand Up @@ -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){
Expand All @@ -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);
},
Expand Down Expand Up @@ -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}'],
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -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": {
Expand Down

0 comments on commit 2c7fa90

Please sign in to comment.