Compare commits
9 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
ac57a9bae0 | ||
|
|
3f2f9d702c | ||
|
|
c0bd1d5565 | ||
|
|
263f280395 | ||
|
|
5d18af8619 | ||
|
|
a41d2c6c2a | ||
|
|
234da67b0d | ||
|
|
c024e203a8 | ||
|
|
cde04a1993 |
1
.gitignore
vendored
1
.gitignore
vendored
@@ -2,3 +2,4 @@
|
||||
*.iml
|
||||
node_modules/
|
||||
package-lock.json
|
||||
.DS_Store
|
||||
|
||||
@@ -59,4 +59,4 @@ lunar是一款无第三方依赖的公历(阳历)、农历(阴历、老黄历)
|
||||
|
||||
## 文档
|
||||
|
||||
请移步至 [http://6tail.cn/calendar/api.html](http://6tail.cn/calendar/api.html "http://6tail.cn/calendar/api.html")
|
||||
请移步至 [https://6tail.cn/calendar/api.html](https://6tail.cn/calendar/api.html "https://6tail.cn/calendar/api.html")
|
||||
|
||||
@@ -59,4 +59,4 @@ Output:
|
||||
|
||||
## Documentation
|
||||
|
||||
Please visit [http://6tail.cn/calendar/api.html](http://6tail.cn/calendar/api.html "http://6tail.cn/calendar/api.html")
|
||||
Please visit [https://6tail.cn/calendar/api.html](https://6tail.cn/calendar/api.html "https://6tail.cn/calendar/api.html")
|
||||
|
||||
@@ -147,3 +147,33 @@ test('身宫', () => {
|
||||
const eightChar = lunar.getEightChar();
|
||||
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('庚申');
|
||||
});
|
||||
|
||||
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('戊子');
|
||||
});
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
var {HolidayUtil} = require('../lunar');
|
||||
const {HolidayUtil} = require('../lunar');
|
||||
|
||||
test('test1', () => {
|
||||
expect(HolidayUtil.getHoliday('2020-01-01') + '').toBe('2020-01-01 元旦节 2020-01-01');
|
||||
@@ -42,3 +42,12 @@ test('test1', () => {
|
||||
test('test2', () => {
|
||||
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);
|
||||
});
|
||||
|
||||
@@ -93,7 +93,7 @@ test('test7', () => {
|
||||
|
||||
test('test8', () => {
|
||||
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', () => {
|
||||
|
||||
@@ -413,16 +413,6 @@ test('test022', () => {
|
||||
expect(lunar.getSolar().toString()).toBe('2033-12-22');
|
||||
});
|
||||
|
||||
test('test023', () => {
|
||||
const lunar = Lunar.fromYmd(2022, 1, 1);
|
||||
expect(lunar.getYearNineStar().toString()).toBe('六白金开阳');
|
||||
});
|
||||
|
||||
test('test024', () => {
|
||||
const lunar = Lunar.fromYmd(2033, 1, 1);
|
||||
expect(lunar.getYearNineStar().toString()).toBe('四绿木天权');
|
||||
});
|
||||
|
||||
test('test025', () => {
|
||||
const solar = Solar.fromYmdHms(2021, 6, 7, 21, 18, 0);
|
||||
expect(solar.getLunar().toString()).toBe('二〇二一年四月廿七');
|
||||
|
||||
@@ -87,3 +87,8 @@ test('test17', () => {
|
||||
const year = LunarYear.fromYear(2004);
|
||||
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]);
|
||||
});
|
||||
|
||||
16
__tests__/NineStar.test.js
Normal file
16
__tests__/NineStar.test.js
Normal file
@@ -0,0 +1,16 @@
|
||||
const {Solar, Lunar} = require('../lunar');
|
||||
|
||||
test('test1', () => {
|
||||
const lunar = Solar.fromYmd(1985, 2, 19).getLunar();
|
||||
expect(lunar.getYearNineStar().getNumber()).toBe('六');
|
||||
});
|
||||
|
||||
test('test023', () => {
|
||||
const lunar = Lunar.fromYmd(2022, 1, 1);
|
||||
expect(lunar.getYearNineStar().toString()).toBe('六白金开阳');
|
||||
});
|
||||
|
||||
test('test024', () => {
|
||||
const lunar = Lunar.fromYmd(2033, 1, 1);
|
||||
expect(lunar.getYearNineStar().toString()).toBe('四绿木天权');
|
||||
});
|
||||
@@ -46,3 +46,13 @@ test('13', () => {
|
||||
var solar = Solar.fromYmd(1996, 3, 25);
|
||||
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()', () => {
|
||||
const season = SolarSeason.fromYm(2019, 5);
|
||||
expect(season.toString()).toBe('2019.2');
|
||||
expect(season.next(1).toString()).toBe('2019.3');
|
||||
const month = SolarMonth.fromYm(2019, 5);
|
||||
expect(month.toString()).toBe('2019-5');
|
||||
expect(month.next(1).toString()).toBe('2019-6');
|
||||
});
|
||||
|
||||
test('toFullString()', () => {
|
||||
const season = SolarSeason.fromYm(2019, 5);
|
||||
expect(season.toFullString()).toBe('2019年2季度');
|
||||
expect(season.next(1).toFullString()).toBe('2019年3季度');
|
||||
const month = SolarMonth.fromYm(2019, 5);
|
||||
expect(month.toFullString()).toBe('2019年5月');
|
||||
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()', () => {
|
||||
const month = SolarMonth.fromYm(2019, 5);
|
||||
expect(month.toString()).toBe('2019-5');
|
||||
expect(month.next(1).toString()).toBe('2019-6');
|
||||
const season = SolarSeason.fromYm(2019, 5);
|
||||
expect(season.toString()).toBe('2019.2');
|
||||
expect(season.next(1).toString()).toBe('2019.3');
|
||||
});
|
||||
|
||||
test('toFullString()', () => {
|
||||
const month = SolarMonth.fromYm(2019, 5);
|
||||
expect(month.toFullString()).toBe('2019年5月');
|
||||
expect(month.next(1).toFullString()).toBe('2019年6月');
|
||||
const season = SolarSeason.fromYm(2019, 5);
|
||||
expect(season.toFullString()).toBe('2019年2季度');
|
||||
expect(season.next(1).toFullString()).toBe('2019年3季度');
|
||||
});
|
||||
|
||||
@@ -83,3 +83,15 @@ test('test14', () => {
|
||||
const lunar = solar.getLunar();
|
||||
expect(lunar.getHou()).toBe('立夏 三候');
|
||||
});
|
||||
|
||||
test('test15', () => {
|
||||
const solar = Solar.fromYmd(2022, 8, 22);
|
||||
const lunar = solar.getLunar();
|
||||
expect(lunar.getWuHou()).toBe('寒蝉鸣');
|
||||
});
|
||||
|
||||
test('test16', () => {
|
||||
const solar = Solar.fromYmd(2022, 8, 23);
|
||||
const lunar = solar.getLunar();
|
||||
expect(lunar.getWuHou()).toBe('鹰乃祭鸟');
|
||||
});
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "lunar-javascript",
|
||||
"version": "1.2.30",
|
||||
"version": "1.2.37",
|
||||
"description": "lunar is a calendar library for Solar and Chinese Lunar.",
|
||||
"main": "index.js",
|
||||
"scripts": {
|
||||
@@ -50,6 +50,5 @@
|
||||
"homepage": "https://github.com/6tail/lunar-javascript",
|
||||
"devDependencies": {
|
||||
"jest": "^26.6.3"
|
||||
},
|
||||
"dependencies": {}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user