Compare commits
11 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
c024e203a8 | ||
|
|
cde04a1993 | ||
|
|
69f0101c15 | ||
|
|
66d16db39e | ||
|
|
98fb502c02 | ||
|
|
44a2b408cf | ||
|
|
26557902f6 | ||
|
|
1e7f33e048 | ||
|
|
988d3f60a7 | ||
|
|
9bfb4ea312 | ||
|
|
004899148d |
@@ -147,3 +147,24 @@ test('身宫', () => {
|
|||||||
const eightChar = lunar.getEightChar();
|
const eightChar = lunar.getEightChar();
|
||||||
expect(eightChar.getShenGong()).toBe('壬午');
|
expect(eightChar.getShenGong()).toBe('壬午');
|
||||||
});
|
});
|
||||||
|
|
||||||
|
test('身宫1', () => {
|
||||||
|
const solar = Solar.fromYmdHms(1994, 12, 6, 2, 0, 0);
|
||||||
|
const lunar = solar.getLunar();
|
||||||
|
const eightChar = lunar.getEightChar();
|
||||||
|
expect(eightChar.getShenGong()).toBe('丁丑');
|
||||||
|
});
|
||||||
|
|
||||||
|
test('身宫2', () => {
|
||||||
|
const solar = Solar.fromYmdHms(1990, 12, 11, 6, 0, 0);
|
||||||
|
const lunar = solar.getLunar();
|
||||||
|
const eightChar = lunar.getEightChar();
|
||||||
|
expect(eightChar.getShenGong()).toBe('庚辰');
|
||||||
|
});
|
||||||
|
|
||||||
|
test('身宫3', () => {
|
||||||
|
const solar = Solar.fromYmdHms(1993, 5, 23, 4, 0, 0);
|
||||||
|
const lunar = solar.getLunar();
|
||||||
|
const eightChar = lunar.getEightChar();
|
||||||
|
expect(eightChar.getShenGong()).toBe('庚申');
|
||||||
|
});
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
var {HolidayUtil} = require('../lunar');
|
const {HolidayUtil} = require('../lunar');
|
||||||
|
|
||||||
test('test1', () => {
|
test('test1', () => {
|
||||||
expect(HolidayUtil.getHoliday('2020-01-01') + '').toBe('2020-01-01 元旦节 2020-01-01');
|
expect(HolidayUtil.getHoliday('2020-01-01') + '').toBe('2020-01-01 元旦节 2020-01-01');
|
||||||
@@ -42,3 +42,12 @@ test('test1', () => {
|
|||||||
test('test2', () => {
|
test('test2', () => {
|
||||||
expect(HolidayUtil.getHoliday('2016-10-04').getTarget()).toBe('2016-10-01');
|
expect(HolidayUtil.getHoliday('2016-10-04').getTarget()).toBe('2016-10-01');
|
||||||
});
|
});
|
||||||
|
|
||||||
|
test('testRemove', () => {
|
||||||
|
let holiday = HolidayUtil.getHoliday('2010-01-01');
|
||||||
|
expect(holiday.getName()).toBe('元旦');
|
||||||
|
|
||||||
|
HolidayUtil.fix('20100101~000000000000000000000000000');
|
||||||
|
holiday = HolidayUtil.getHoliday('2010-01-01');
|
||||||
|
expect(holiday).toBe(null);
|
||||||
|
});
|
||||||
|
|||||||
@@ -415,12 +415,12 @@ test('test022', () => {
|
|||||||
|
|
||||||
test('test023', () => {
|
test('test023', () => {
|
||||||
const lunar = Lunar.fromYmd(2022, 1, 1);
|
const lunar = Lunar.fromYmd(2022, 1, 1);
|
||||||
expect(lunar.getYearNineStar().toString()).toBe('五黄土玉衡');
|
expect(lunar.getYearNineStar().toString()).toBe('六白金开阳');
|
||||||
});
|
});
|
||||||
|
|
||||||
test('test024', () => {
|
test('test024', () => {
|
||||||
const lunar = Lunar.fromYmd(2033, 1, 1);
|
const lunar = Lunar.fromYmd(2033, 1, 1);
|
||||||
expect(lunar.getYearNineStar().toString()).toBe('三碧木天玑');
|
expect(lunar.getYearNineStar().toString()).toBe('四绿木天权');
|
||||||
});
|
});
|
||||||
|
|
||||||
test('test025', () => {
|
test('test025', () => {
|
||||||
@@ -570,3 +570,23 @@ test('test052', () => {
|
|||||||
const lunar = Solar.fromYmd(2011, 11, 12).getLunar();
|
const lunar = Solar.fromYmd(2011, 11, 12).getLunar();
|
||||||
expect(lunar.getDayPositionTai()).toBe('厕灶厨 外西南');
|
expect(lunar.getDayPositionTai()).toBe('厕灶厨 外西南');
|
||||||
});
|
});
|
||||||
|
|
||||||
|
test('test053', () => {
|
||||||
|
const lunar = Solar.fromYmd(1722, 9, 25).getLunar();
|
||||||
|
expect(lunar.getOtherFestivals() + '').toBe('秋社');
|
||||||
|
});
|
||||||
|
|
||||||
|
test('test054', () => {
|
||||||
|
const lunar = Solar.fromYmd(840, 9, 14).getLunar();
|
||||||
|
expect(lunar.getOtherFestivals() + '').toBe('秋社');
|
||||||
|
});
|
||||||
|
|
||||||
|
test('test055', () => {
|
||||||
|
const lunar = Solar.fromYmd(2022, 3, 16).getLunar();
|
||||||
|
expect(lunar.getOtherFestivals() + '').toBe('春社');
|
||||||
|
});
|
||||||
|
|
||||||
|
test('test056', () => {
|
||||||
|
const lunar = Solar.fromYmd(2021, 3, 21).getLunar();
|
||||||
|
expect(lunar.getOtherFestivals() + '').toBe('春社');
|
||||||
|
});
|
||||||
|
|||||||
@@ -87,3 +87,8 @@ test('test17', () => {
|
|||||||
const year = LunarYear.fromYear(2004);
|
const year = LunarYear.fromYear(2004);
|
||||||
expect(year.getYun()).toBe('八运');
|
expect(year.getYun()).toBe('八运');
|
||||||
});
|
});
|
||||||
|
|
||||||
|
test('test18', () => {
|
||||||
|
const year = LunarYear.fromYear(2022);
|
||||||
|
expect(year.getJieQiJulianDays()).toStrictEqual([2459555.7478605337, 2459570.499405936, 2459585.217980813, 2459599.9437018055, 2459614.7018054826, 2459629.5297495862, 2459644.446920318, 2459659.4814200983, 2459674.6389274267, 2459689.9334118855, 2459705.3512322665, 2459720.890569021, 2459736.517794922, 2459752.2178259823, 2459767.9429320656, 2459783.6713957503, 2459799.3534378354, 2459814.969435438, 2459830.480632029, 2459845.8774438635, 2459861.140466851, 2459876.2746654437, 2459891.281458942, 2459906.1807667296, 2459920.9903281447, 2459935.741672728, 2459950.461561025, 2459965.187040542, 2459979.9460747372, 2459994.7736723446, 2460009.6916930582]);
|
||||||
|
});
|
||||||
|
|||||||
@@ -31,3 +31,18 @@ test('9', () => {
|
|||||||
test('10', () => {
|
test('10', () => {
|
||||||
expect(SolarUtil.isLeapYear(1500)).toBe(false);
|
expect(SolarUtil.isLeapYear(1500)).toBe(false);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
test('11', () => {
|
||||||
|
var solar = Solar.fromYmd(2022, 3, 28);
|
||||||
|
expect(solar.getFestivals() + '').toBe('全国中小学生安全教育日');
|
||||||
|
});
|
||||||
|
|
||||||
|
test('12', () => {
|
||||||
|
var solar = Solar.fromYmd(2021, 3, 29);
|
||||||
|
expect(solar.getFestivals() + '').toBe('全国中小学生安全教育日');
|
||||||
|
});
|
||||||
|
|
||||||
|
test('13', () => {
|
||||||
|
var solar = Solar.fromYmd(1996, 3, 25);
|
||||||
|
expect(solar.getFestivals() + '').toBe('全国中小学生安全教育日');
|
||||||
|
});
|
||||||
|
|||||||
@@ -19,3 +19,21 @@ test('testFromSunday', () => {
|
|||||||
expect(week.getFirstDay().toString()).toBe('2019-04-28');
|
expect(week.getFirstDay().toString()).toBe('2019-04-28');
|
||||||
expect(week.getFirstDayInMonth().toString()).toBe('2019-05-01');
|
expect(week.getFirstDayInMonth().toString()).toBe('2019-05-01');
|
||||||
});
|
});
|
||||||
|
|
||||||
|
test('test1', () => {
|
||||||
|
const start = 0;
|
||||||
|
const week = SolarWeek.fromYmd(2022, 5, 1, start);
|
||||||
|
expect(week.getIndex()).toBe(1);
|
||||||
|
});
|
||||||
|
|
||||||
|
test('test2', () => {
|
||||||
|
const start = 2;
|
||||||
|
const week = SolarWeek.fromYmd(2021, 5, 4, start);
|
||||||
|
expect(week.getIndex()).toBe(2);
|
||||||
|
});
|
||||||
|
|
||||||
|
test('test3', () => {
|
||||||
|
const start = 0;
|
||||||
|
const week = SolarWeek.fromYmd(2022, 3, 6, start);
|
||||||
|
expect(week.getIndexInYear()).toBe(11);
|
||||||
|
});
|
||||||
|
|||||||
@@ -77,3 +77,9 @@ test('test13', () => {
|
|||||||
const lunar = solar.getLunar();
|
const lunar = solar.getLunar();
|
||||||
expect(lunar.getHou()).toBe('小寒 初候');
|
expect(lunar.getHou()).toBe('小寒 初候');
|
||||||
});
|
});
|
||||||
|
|
||||||
|
test('test14', () => {
|
||||||
|
const solar = Solar.fromYmd(2022,5,20);
|
||||||
|
const lunar = solar.getLunar();
|
||||||
|
expect(lunar.getHou()).toBe('立夏 三候');
|
||||||
|
});
|
||||||
|
|||||||
@@ -31,3 +31,30 @@ it('test3', () => {
|
|||||||
expect(yun.getStartDay()).toBe(0);
|
expect(yun.getStartDay()).toBe(0);
|
||||||
expect(yun.getStartSolar().toYmd()).toBe('2020-02-06');
|
expect(yun.getStartSolar().toYmd()).toBe('2020-02-06');
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it('test4', () => {
|
||||||
|
const solar = Solar.fromYmdHms(2022, 3, 9, 20, 51, 0);
|
||||||
|
const lunar = solar.getLunar();
|
||||||
|
const eightChar = lunar.getEightChar();
|
||||||
|
const yun = eightChar.getYun(1);
|
||||||
|
expect(yun.getStartSolar().toYmd()).toBe('2030-12-19');
|
||||||
|
});
|
||||||
|
|
||||||
|
it('test5', () => {
|
||||||
|
const solar = Solar.fromYmdHms(2022, 3, 9, 20, 51, 0);
|
||||||
|
const lunar = solar.getLunar();
|
||||||
|
const eightChar = lunar.getEightChar();
|
||||||
|
const yun = eightChar.getYun(1, 2);
|
||||||
|
expect(yun.getStartYear()).toBe(8);
|
||||||
|
expect(yun.getStartMonth()).toBe(9);
|
||||||
|
expect(yun.getStartDay()).toBe(2);
|
||||||
|
expect(yun.getStartSolar().toYmd()).toBe('2030-12-12');
|
||||||
|
});
|
||||||
|
|
||||||
|
it('test6', () => {
|
||||||
|
const solar = Solar.fromYmdHms(2018, 6, 11, 9, 30, 0);
|
||||||
|
const lunar = solar.getLunar();
|
||||||
|
const eightChar = lunar.getEightChar();
|
||||||
|
const yun = eightChar.getYun(0, 2);
|
||||||
|
expect(yun.getStartSolar().toYmd()).toBe('2020-03-21');
|
||||||
|
});
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "lunar-javascript",
|
"name": "lunar-javascript",
|
||||||
"version": "1.2.21",
|
"version": "1.2.32",
|
||||||
"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": {
|
||||||
|
|||||||
Reference in New Issue
Block a user