Compare commits
2 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
a41d2c6c2a | ||
|
|
234da67b0d |
@@ -168,3 +168,12 @@ test('身宫3', () => {
|
|||||||
const eightChar = lunar.getEightChar();
|
const eightChar = lunar.getEightChar();
|
||||||
expect(eightChar.getShenGong()).toBe('庚申');
|
expect(eightChar.getShenGong()).toBe('庚申');
|
||||||
});
|
});
|
||||||
|
|
||||||
|
test('test11', () => {
|
||||||
|
const lunar = Lunar.fromYmdHms(1987, 12, 28, 23, 30, 0);
|
||||||
|
const eightChar = lunar.getEightChar();
|
||||||
|
expect(eightChar.getYear()).toBe('戊辰');
|
||||||
|
expect(eightChar.getMonth()).toBe('甲寅');
|
||||||
|
expect(eightChar.getDay()).toBe('庚子');
|
||||||
|
expect(eightChar.getTime()).toBe('戊子');
|
||||||
|
});
|
||||||
|
|||||||
@@ -93,7 +93,7 @@ test('test7', () => {
|
|||||||
|
|
||||||
test('test8', () => {
|
test('test8', () => {
|
||||||
const lunar = Lunar.fromYmd(2050, 12, 1);
|
const lunar = Lunar.fromYmd(2050, 12, 1);
|
||||||
expect(lunar.getJieQiTable()['大雪'].toYmdHms()).toBe('2050-12-07 06:41:00');
|
expect(lunar.getJieQiTable()['DA_XUE'].toYmdHms()).toBe('2050-12-07 06:41:00');
|
||||||
});
|
});
|
||||||
|
|
||||||
test('test9', () => {
|
test('test9', () => {
|
||||||
|
|||||||
@@ -46,3 +46,13 @@ test('13', () => {
|
|||||||
var solar = Solar.fromYmd(1996, 3, 25);
|
var solar = Solar.fromYmd(1996, 3, 25);
|
||||||
expect(solar.getFestivals() + '').toBe('全国中小学生安全教育日');
|
expect(solar.getFestivals() + '').toBe('全国中小学生安全教育日');
|
||||||
});
|
});
|
||||||
|
|
||||||
|
test('14', () => {
|
||||||
|
const solar = Solar.fromYmd(1583, 1, 13);
|
||||||
|
expect(solar.getLunar().toString()).toBe('一五八二年腊月二十');
|
||||||
|
});
|
||||||
|
|
||||||
|
test('15', () => {
|
||||||
|
const solar = Solar.fromYmd(1583, 1, 14);
|
||||||
|
expect(solar.getLunar().toString()).toBe('一五八二年腊月廿一');
|
||||||
|
});
|
||||||
|
|||||||
@@ -1,13 +1,37 @@
|
|||||||
var {SolarSeason} = require('../lunar');
|
var {SolarMonth} = require('../lunar');
|
||||||
|
|
||||||
test('toString()', () => {
|
test('toString()', () => {
|
||||||
const season = SolarSeason.fromYm(2019, 5);
|
const month = SolarMonth.fromYm(2019, 5);
|
||||||
expect(season.toString()).toBe('2019.2');
|
expect(month.toString()).toBe('2019-5');
|
||||||
expect(season.next(1).toString()).toBe('2019.3');
|
expect(month.next(1).toString()).toBe('2019-6');
|
||||||
});
|
});
|
||||||
|
|
||||||
test('toFullString()', () => {
|
test('toFullString()', () => {
|
||||||
const season = SolarSeason.fromYm(2019, 5);
|
const month = SolarMonth.fromYm(2019, 5);
|
||||||
expect(season.toFullString()).toBe('2019年2季度');
|
expect(month.toFullString()).toBe('2019年5月');
|
||||||
expect(season.next(1).toFullString()).toBe('2019年3季度');
|
expect(month.next(1).toFullString()).toBe('2019年6月');
|
||||||
|
});
|
||||||
|
|
||||||
|
test('test1', () => {
|
||||||
|
const month = SolarMonth.fromYm(2022, 7);
|
||||||
|
const weeks = month.getWeeks(0);
|
||||||
|
const lastWeek = weeks[weeks.length - 1];
|
||||||
|
const days = lastWeek.getDays();
|
||||||
|
expect(days[0].toFullString()).toBe('2022-07-31 00:00:00 星期日 狮子座');
|
||||||
|
});
|
||||||
|
|
||||||
|
test('test2', () => {
|
||||||
|
const month = SolarMonth.fromYm(2022, 7);
|
||||||
|
const weeks = month.getWeeks(0);
|
||||||
|
const lastWeek = weeks[weeks.length - 1];
|
||||||
|
const days = lastWeek.getDays();
|
||||||
|
expect(days[1].toFullString()).toBe('2022-08-01 00:00:00 星期一 (建军节) 狮子座');
|
||||||
|
});
|
||||||
|
|
||||||
|
test('test3', () => {
|
||||||
|
const month = SolarMonth.fromYm(2022, 7);
|
||||||
|
const weeks = month.getWeeks(0);
|
||||||
|
const lastWeek = weeks[weeks.length - 1];
|
||||||
|
const days = lastWeek.getDays();
|
||||||
|
expect(days[6].toFullString()).toBe('2022-08-06 00:00:00 星期六 狮子座');
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -1,13 +1,13 @@
|
|||||||
var {SolarMonth} = require('../lunar');
|
var {SolarSeason} = require('../lunar');
|
||||||
|
|
||||||
test('toString()', () => {
|
test('toString()', () => {
|
||||||
const month = SolarMonth.fromYm(2019, 5);
|
const season = SolarSeason.fromYm(2019, 5);
|
||||||
expect(month.toString()).toBe('2019-5');
|
expect(season.toString()).toBe('2019.2');
|
||||||
expect(month.next(1).toString()).toBe('2019-6');
|
expect(season.next(1).toString()).toBe('2019.3');
|
||||||
});
|
});
|
||||||
|
|
||||||
test('toFullString()', () => {
|
test('toFullString()', () => {
|
||||||
const month = SolarMonth.fromYm(2019, 5);
|
const season = SolarSeason.fromYm(2019, 5);
|
||||||
expect(month.toFullString()).toBe('2019年5月');
|
expect(season.toFullString()).toBe('2019年2季度');
|
||||||
expect(month.next(1).toFullString()).toBe('2019年6月');
|
expect(season.next(1).toFullString()).toBe('2019年3季度');
|
||||||
});
|
});
|
||||||
|
|||||||
26
lunar.js
26
lunar.js
@@ -567,6 +567,9 @@
|
|||||||
}
|
}
|
||||||
var noon = Solar.fromJulianDay(m.getFirstJulianDay() + lunarDay - 1);
|
var noon = Solar.fromJulianDay(m.getFirstJulianDay() + lunarDay - 1);
|
||||||
var solar = Solar.fromYmdHms(noon.getYear(), noon.getMonth(), noon.getDay(), hour, minute, second);
|
var solar = Solar.fromYmdHms(noon.getYear(), noon.getMonth(), noon.getDay(), hour, minute, second);
|
||||||
|
if (noon.getYear() !== lunarYear) {
|
||||||
|
y = LunarYear.fromYear(noon.getYear());
|
||||||
|
}
|
||||||
return _new(lunarYear, lunarMonth, lunarDay, hour, minute, second, solar, y);
|
return _new(lunarYear, lunarMonth, lunarDay, hour, minute, second, solar, y);
|
||||||
};
|
};
|
||||||
var _new = function(year,month,day,hour,minute,second,solar,ly){
|
var _new = function(year,month,day,hour,minute,second,solar,ly){
|
||||||
@@ -1068,7 +1071,7 @@
|
|||||||
if(f){
|
if(f){
|
||||||
l.push(f);
|
l.push(f);
|
||||||
}
|
}
|
||||||
if (Math.abs(this._p.month) === 12 && this._p.day >= 29 && this._p.year != this.next(1).getYear()) {
|
if (Math.abs(this._p.month) === 12 && this._p.day >= 29 && this._p.year !== this.next(1).getYear()) {
|
||||||
l.push('除夕');
|
l.push('除夕');
|
||||||
}
|
}
|
||||||
return l;
|
return l;
|
||||||
@@ -1223,7 +1226,7 @@
|
|||||||
_getYearNineStar:function(yearInGanZhi){
|
_getYearNineStar:function(yearInGanZhi){
|
||||||
var index = LunarUtil.getJiaZiIndex(yearInGanZhi) + 1;
|
var index = LunarUtil.getJiaZiIndex(yearInGanZhi) + 1;
|
||||||
var yearOffset = 0;
|
var yearOffset = 0;
|
||||||
if (index != LunarUtil.getJiaZiIndex(this.getYearInGanZhi()) + 1) {
|
if (index !== LunarUtil.getJiaZiIndex(this.getYearInGanZhi()) + 1) {
|
||||||
yearOffset = -1;
|
yearOffset = -1;
|
||||||
}
|
}
|
||||||
var yuan = Math.floor((this._p.year + yearOffset + 2696) / 60) % 3;
|
var yuan = Math.floor((this._p.year + yearOffset + 2696) / 60) % 3;
|
||||||
@@ -1377,7 +1380,7 @@
|
|||||||
var j;
|
var j;
|
||||||
for(i=0,j=Lunar.JIE_QI.length;i<j;i++){
|
for(i=0,j=Lunar.JIE_QI.length;i<j;i++){
|
||||||
if(Lunar.JIE_QI[i]===name){
|
if(Lunar.JIE_QI[i]===name){
|
||||||
if(i%2==0){
|
if(i%2===0){
|
||||||
qi = true;
|
qi = true;
|
||||||
}else{
|
}else{
|
||||||
jie = true;
|
jie = true;
|
||||||
@@ -1945,9 +1948,22 @@
|
|||||||
},
|
},
|
||||||
getWeeks:function(start){
|
getWeeks:function(start){
|
||||||
var l = [];
|
var l = [];
|
||||||
var weeks = SolarUtil.getWeeksOfMonth(this._p.year,this._p.month,start);
|
var cy = this._p.year;
|
||||||
|
var cm = this._p.month;
|
||||||
|
var weeks = SolarUtil.getWeeksOfMonth(cy, cm, start);
|
||||||
|
var days = SolarUtil.getDaysOfMonth(cy, cm);
|
||||||
for(var i = 0;i<weeks;i++){
|
for(var i = 0;i<weeks;i++){
|
||||||
l.push(SolarWeek.fromYmd(this._p.year,this._p.month,1+i*7,start));
|
var y = cy;
|
||||||
|
var m = cm;
|
||||||
|
var d = 1 + i * 7;
|
||||||
|
if (d > days) {
|
||||||
|
d -= days;
|
||||||
|
m++;
|
||||||
|
if (m > 12) {
|
||||||
|
y++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
l.push(SolarWeek.fromYmd(y, m, d, start));
|
||||||
}
|
}
|
||||||
return l;
|
return l;
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "lunar-javascript",
|
"name": "lunar-javascript",
|
||||||
"version": "1.2.32",
|
"version": "1.2.34",
|
||||||
"description": "lunar is a calendar library for Solar and Chinese Lunar.",
|
"description": "lunar is a calendar library for Solar and Chinese Lunar.",
|
||||||
"main": "index.js",
|
"main": "index.js",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
@@ -50,6 +50,5 @@
|
|||||||
"homepage": "https://github.com/6tail/lunar-javascript",
|
"homepage": "https://github.com/6tail/lunar-javascript",
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"jest": "^26.6.3"
|
"jest": "^26.6.3"
|
||||||
},
|
}
|
||||||
"dependencies": {}
|
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user