var {Solar, Lunar, LunarYear} = require('../lunar'); test('干支', () => { let solar = Solar.fromYmdHms(2020, 1, 1, 13, 22, 0); let lunar = solar.getLunar(); expect(lunar.getYearInGanZhi()).toBe('己亥'); expect(lunar.getYearInGanZhiByLiChun()).toBe('己亥'); expect(lunar.getYearInGanZhiExact()).toBe('己亥'); expect(lunar.getMonthInGanZhi()).toBe('丙子'); expect(lunar.getMonthInGanZhiExact()).toBe('丙子'); //小寒 solar = Solar.fromYmdHms(2020, 1, 6, 13, 22, 0); lunar = solar.getLunar(); expect(lunar.getYearInGanZhi()).toBe('己亥'); expect(lunar.getYearInGanZhiByLiChun()).toBe('己亥'); expect(lunar.getYearInGanZhiExact()).toBe('己亥'); expect(lunar.getMonthInGanZhi()).toBe('丁丑'); expect(lunar.getMonthInGanZhiExact()).toBe('丁丑'); solar = Solar.fromYmdHms(2020, 1, 20, 13, 22, 0); lunar = solar.getLunar(); expect(lunar.getYearInGanZhi()).toBe('己亥'); expect(lunar.getYearInGanZhiByLiChun()).toBe('己亥'); expect(lunar.getYearInGanZhiExact()).toBe('己亥'); expect(lunar.getMonthInGanZhi()).toBe('丁丑'); expect(lunar.getMonthInGanZhiExact()).toBe('丁丑'); //春节 solar = Solar.fromYmdHms(2020, 1, 25, 13, 22, 0); lunar = solar.getLunar(); expect(lunar.getYearInGanZhi()).toBe('庚子'); expect(lunar.getYearInGanZhiByLiChun()).toBe('己亥'); expect(lunar.getYearInGanZhiExact()).toBe('己亥'); expect(lunar.getMonthInGanZhi()).toBe('丁丑'); expect(lunar.getMonthInGanZhiExact()).toBe('丁丑'); solar = Solar.fromYmdHms(2020, 1, 30, 13, 22, 0); lunar = solar.getLunar(); expect(lunar.getYearInGanZhi()).toBe('庚子'); expect(lunar.getYearInGanZhiByLiChun()).toBe('己亥'); expect(lunar.getYearInGanZhiExact()).toBe('己亥'); expect(lunar.getMonthInGanZhi()).toBe('丁丑'); expect(lunar.getMonthInGanZhiExact()).toBe('丁丑'); solar = Solar.fromYmdHms(2020, 2, 1, 13, 22, 0); lunar = solar.getLunar(); expect(lunar.getYearInGanZhi()).toBe('庚子'); expect(lunar.getYearInGanZhiByLiChun()).toBe('己亥'); expect(lunar.getYearInGanZhiExact()).toBe('己亥'); expect(lunar.getMonthInGanZhi()).toBe('丁丑'); expect(lunar.getMonthInGanZhiExact()).toBe('丁丑'); solar = Solar.fromYmdHms(2020, 2, 4, 13, 22, 0); lunar = solar.getLunar(); expect(lunar.getYearInGanZhi()).toBe('庚子'); expect(lunar.getYearInGanZhiByLiChun()).toBe('庚子'); expect(lunar.getYearInGanZhiExact()).toBe('己亥'); expect(lunar.getMonthInGanZhi()).toBe('戊寅'); expect(lunar.getMonthInGanZhiExact()).toBe('丁丑'); solar = Solar.fromYmdHms(2020, 2, 4, 18, 22, 0); lunar = solar.getLunar(); expect(lunar.getYearInGanZhi()).toBe('庚子'); expect(lunar.getYearInGanZhiByLiChun()).toBe('庚子'); expect(lunar.getYearInGanZhiExact()).toBe('庚子'); expect(lunar.getMonthInGanZhi()).toBe('戊寅'); expect(lunar.getMonthInGanZhiExact()).toBe('戊寅'); solar = Solar.fromYmdHms(2020, 2, 5, 13, 22, 0); lunar = solar.getLunar(); expect(lunar.getYearInGanZhi()).toBe('庚子'); expect(lunar.getYearInGanZhiByLiChun()).toBe('庚子'); expect(lunar.getYearInGanZhiExact()).toBe('庚子'); expect(lunar.getMonthInGanZhi()).toBe('戊寅'); expect(lunar.getMonthInGanZhiExact()).toBe('戊寅'); solar = Solar.fromYmdHms(2020, 5, 22, 13, 22, 0); lunar = solar.getLunar(); expect(lunar.getYearInGanZhi()).toBe('庚子'); expect(lunar.getYearInGanZhiByLiChun()).toBe('庚子'); expect(lunar.getYearInGanZhiExact()).toBe('庚子'); expect(lunar.getMonthInGanZhi()).toBe('辛巳'); expect(lunar.getMonthInGanZhiExact()).toBe('辛巳'); solar = Solar.fromYmdHms(2020, 5, 23, 13, 22, 0); lunar = solar.getLunar(); expect(lunar.getYearInGanZhi()).toBe('庚子'); expect(lunar.getYearInGanZhiByLiChun()).toBe('庚子'); expect(lunar.getYearInGanZhiExact()).toBe('庚子'); expect(lunar.getMonthInGanZhi()).toBe('辛巳'); expect(lunar.getMonthInGanZhiExact()).toBe('辛巳'); solar = Solar.fromYmdHms(2020, 5, 29, 13, 22, 0); lunar = solar.getLunar(); expect(lunar.getYearInGanZhi()).toBe('庚子'); expect(lunar.getYearInGanZhiByLiChun()).toBe('庚子'); expect(lunar.getYearInGanZhiExact()).toBe('庚子'); expect(lunar.getMonthInGanZhi()).toBe('辛巳'); expect(lunar.getMonthInGanZhiExact()).toBe('辛巳'); solar = Solar.fromYmdHms(2020, 6, 1, 13, 22, 0); lunar = solar.getLunar(); expect(lunar.getYearInGanZhi()).toBe('庚子'); expect(lunar.getYearInGanZhiByLiChun()).toBe('庚子'); expect(lunar.getYearInGanZhiExact()).toBe('庚子'); expect(lunar.getMonthInGanZhi()).toBe('辛巳'); expect(lunar.getMonthInGanZhiExact()).toBe('辛巳'); solar = Solar.fromYmdHms(2020, 6, 29, 13, 22, 0); lunar = solar.getLunar(); expect(lunar.getYearInGanZhi()).toBe('庚子'); expect(lunar.getYearInGanZhiByLiChun()).toBe('庚子'); expect(lunar.getYearInGanZhiExact()).toBe('庚子'); expect(lunar.getMonthInGanZhi()).toBe('壬午'); expect(lunar.getMonthInGanZhiExact()).toBe('壬午'); solar = Solar.fromYmdHms(2019, 5, 1, 13, 22, 0); lunar = solar.getLunar(); expect(lunar.getYearInGanZhi()).toBe('己亥'); expect(lunar.getYearInGanZhiByLiChun()).toBe('己亥'); expect(lunar.getYearInGanZhiExact()).toBe('己亥'); expect(lunar.getMonthInGanZhi()).toBe('戊辰'); expect(lunar.getMonthInGanZhiExact()).toBe('戊辰'); solar = Solar.fromYmdHms(1986, 5, 29, 13, 22, 0); lunar = solar.getLunar(); expect(lunar.getYearInGanZhi()).toBe('丙寅'); expect(lunar.getYearInGanZhiByLiChun()).toBe('丙寅'); expect(lunar.getYearInGanZhiExact()).toBe('丙寅'); expect(lunar.getMonthInGanZhi()).toBe('癸巳'); expect(lunar.getMonthInGanZhiExact()).toBe('癸巳'); solar = Solar.fromYmdHms(1986, 5, 1, 1, 22, 0); lunar = solar.getLunar(); expect(lunar.getYearInGanZhi()).toBe('丙寅'); expect(lunar.getYearInGanZhiByLiChun()).toBe('丙寅'); expect(lunar.getYearInGanZhiExact()).toBe('丙寅'); expect(lunar.getMonthInGanZhi()).toBe('壬辰'); expect(lunar.getMonthInGanZhiExact()).toBe('壬辰'); solar = Solar.fromYmdHms(1986, 5, 6, 1, 22, 0); lunar = solar.getLunar(); expect(lunar.getYearInGanZhi()).toBe('丙寅'); expect(lunar.getYearInGanZhiByLiChun()).toBe('丙寅'); expect(lunar.getYearInGanZhiExact()).toBe('丙寅'); expect(lunar.getMonthInGanZhi()).toBe('癸巳'); expect(lunar.getMonthInGanZhiExact()).toBe('壬辰'); solar = Solar.fromYmdHms(1986, 5, 6, 23, 22, 0); lunar = solar.getLunar(); expect(lunar.getYearInGanZhi()).toBe('丙寅'); expect(lunar.getYearInGanZhiByLiChun()).toBe('丙寅'); expect(lunar.getYearInGanZhiExact()).toBe('丙寅'); expect(lunar.getMonthInGanZhi()).toBe('癸巳'); expect(lunar.getMonthInGanZhiExact()).toBe('癸巳'); }); test('test8', () => { const lunar = Lunar.fromYmdHms(2020,12,10,13,0,0); expect(lunar.toString()).toBe('二〇二〇年腊月初十'); expect(lunar.getSolar().toString()).toBe('2021-01-22'); }); test('test9', () => { const lunar = Lunar.fromYmdHms(1500,1,1,12,0,0); expect(lunar.getSolar().toString()).toBe('1500-01-31'); }); test('test10', () => { const lunar = Lunar.fromYmdHms(1500,12,29,12,0,0); expect(lunar.getSolar().toString()).toBe('1501-01-18'); }); test('test11', () => { const solar = Solar.fromYmdHms(1500,1,1,12,0,0); expect(solar.getLunar().toString()).toBe('一四九九年腊月初一'); }); test('test12', () => { const solar = Solar.fromYmdHms(1500,12,31,12,0,0); expect(solar.getLunar().toString()).toBe('一五〇〇年腊月十一'); }); test('test13', () => { const solar = Solar.fromYmdHms(1582,10,4,12,0,0); expect(solar.getLunar().toString()).toBe('一五八二年九月十八'); }); test('test14', () => { const solar = Solar.fromYmdHms(1582,10,15,12,0,0); expect(solar.getLunar().toString()).toBe('一五八二年九月十九'); }); test('test15', () => { const lunar = Lunar.fromYmdHms(1582,9,18,12,0,0); expect(lunar.getSolar().toString()).toBe('1582-10-04'); }); test('test16', () => { const lunar = Lunar.fromYmdHms(1582,9,19,12,0,0); expect(lunar.getSolar().toString()).toBe('1582-10-15'); }); test('test17', () => { const lunar = Lunar.fromYmdHms(2019,12,12,11,22,0); expect(lunar.getSolar().toString()).toBe('2020-01-06'); }); test('test18', () => { const solar = Solar.fromYmdHms(2020,2,4,13,22,0); const lunar = solar.getLunar(); expect(lunar.getYearInGanZhi()).toBe('庚子'); expect(lunar.getYearInGanZhiByLiChun()).toBe('庚子'); expect(lunar.getYearInGanZhiExact()).toBe('己亥'); expect(lunar.getMonthInGanZhi()).toBe('戊寅'); expect(lunar.getMonthInGanZhiExact()).toBe('丁丑'); }); test('test19', () => { const solar = Solar.fromYmdHms(2019, 2, 8, 13, 22, 0); const lunar = solar.getLunar(); expect(lunar.getYearInGanZhi()).toBe('己亥'); expect(lunar.getYearInGanZhiByLiChun()).toBe('己亥'); expect(lunar.getYearInGanZhiExact()).toBe('己亥'); expect(lunar.getMonthInGanZhi()).toBe('丙寅'); expect(lunar.getMonthInGanZhiExact()).toBe('丙寅'); }); test('test20', () => { const solar = Solar.fromYmdHms(1988, 2, 15, 23, 30,0); const lunar = solar.getLunar(); expect(lunar.getYearInGanZhi()).toBe('丁卯'); expect(lunar.getYearInGanZhiByLiChun()).toBe('戊辰'); expect(lunar.getYearInGanZhiExact()).toBe('戊辰'); }); test('test21', () => { const solar = Solar.fromYmd(1988, 2, 15); const lunar = solar.getLunar(); expect(lunar.getYearInGanZhi()).toBe('丁卯'); }); test('test22', () => { const solar = Solar.fromYmd(2012, 12, 27); const lunar = solar.getLunar(); expect(lunar.getYearInGanZhi()).toBe('壬辰'); expect(lunar.getMonthInGanZhi()).toBe('壬子'); expect(lunar.getDayInGanZhi()).toBe('壬戌'); }); test('test23', () => { const solar = Solar.fromYmd(2012, 12, 20); const lunar = solar.getLunar(); expect(lunar.getYearInGanZhi()).toBe('壬辰'); expect(lunar.getMonthInGanZhi()).toBe('壬子'); expect(lunar.getDayInGanZhi()).toBe('乙卯'); }); test('test24', () => { const solar = Solar.fromYmd(2012, 11, 20); const lunar = solar.getLunar(); expect(lunar.getYearInGanZhi()).toBe('壬辰'); expect(lunar.getMonthInGanZhi()).toBe('辛亥'); expect(lunar.getDayInGanZhi()).toBe('乙酉'); }); test('test25', () => { const solar = Solar.fromYmd(2012, 10, 20); const lunar = solar.getLunar(); expect(lunar.getYearInGanZhi()).toBe('壬辰'); expect(lunar.getMonthInGanZhi()).toBe('庚戌'); expect(lunar.getDayInGanZhi()).toBe('甲寅'); }); test('test26', () => { const solar = Solar.fromYmd(2012, 9, 20); const lunar = solar.getLunar(); expect(lunar.getYearInGanZhi()).toBe('壬辰'); expect(lunar.getMonthInGanZhi()).toBe('己酉'); expect(lunar.getDayInGanZhi()).toBe('甲申'); }); test('test26', () => { const solar = Solar.fromYmd(2012, 8, 5); const lunar = solar.getLunar(); expect(lunar.getDayInGanZhi()).toBe('戊戌'); }); test('test27', () => { const solar = Solar.fromYmd(2000, 2, 2); const lunar = solar.getLunar(); expect(lunar.getDayInGanZhi()).toBe('庚寅'); }); test('test28', () => { const solar = Solar.fromYmd(1996, 1, 16); const lunar = solar.getLunar(); expect(lunar.getDayInGanZhi()).toBe('壬子'); }); test('test29', () => { const solar = Solar.fromYmd(1997, 2, 16); const lunar = solar.getLunar(); expect(lunar.getDayInGanZhi()).toBe('己丑'); }); test('test30', () => { const solar = Solar.fromYmd(1998, 3, 16); const lunar = solar.getLunar(); expect(lunar.getDayInGanZhi()).toBe('壬戌'); }); test('test31', () => { const solar = Solar.fromYmd(1999, 4, 16); const lunar = solar.getLunar(); expect(lunar.getDayInGanZhi()).toBe('戊戌'); }); test('test32', () => { const solar = Solar.fromYmd(2000, 7, 16); const lunar = solar.getLunar(); expect(lunar.getDayInGanZhi()).toBe('乙亥'); }); test('test33', () => { const solar = Solar.fromYmd(2000, 1, 6); const lunar = solar.getLunar(); expect(lunar.getDayInGanZhi()).toBe('癸亥'); }); test('test34', () => { const solar = Solar.fromYmd(2000, 1, 9); const lunar = solar.getLunar(); expect(lunar.getDayInGanZhi()).toBe('丙寅'); }); test('test35', () => { const lunar = Lunar.fromYmd(2021, 12, 29); expect(lunar.getFestivals()[0]).toBe('除夕'); }); test('test36', () => { const lunar = Lunar.fromYmd(2020, 12, 30); expect(lunar.getFestivals()[0]).toBe('除夕'); }); test('test37', () => { const lunar = Lunar.fromYmd(2020, 12, 29); expect(lunar.getFestivals().length).toBe(0); }); test('test38', () => { const solar = Solar.fromYmd(2022, 1, 31); const lunar = solar.getLunar(); expect(lunar.getFestivals()[0]).toBe('除夕'); }); test('test39', () => { const lunar = Lunar.fromYmd(2033, -11, 1); expect(lunar.getSolar().toYmd()).toBe('2033-12-22'); }); test('test40', () => { const solar = Solar.fromYmdHms(1, 1, 1, 12, 0, 0); expect(solar.getLunar().toString()).toBe('〇年冬月十八'); }); test('test41', () => { const solar = Solar.fromYmdHms(9999, 12, 31, 12, 0, 0); expect(solar.getLunar().toString()).toBe('九九九九年腊月初二'); }); test('test42', () => { const lunar = Lunar.fromYmdHms(0, 11, 18, 12, 0, 0); expect(lunar.getSolar().toString()).toBe('0001-01-01'); }); test('test43', () => { const lunar = Lunar.fromYmdHms(9999, 12, 2, 12, 0, 0); expect(lunar.getSolar().toString()).toBe('9999-12-31'); }); test('test022', () => { const lunar = Lunar.fromYmd(2033, -11, 1); 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('二〇二一年四月廿七'); }); test('test026', () => { const lunar = Lunar.fromYmdHms(2021, 6, 7, 21, 18, 0); expect(lunar.getSolar().toString()).toBe('2021-07-16'); }); test('test027', () => { const solar = Solar.fromYmd(1989, 4, 28); expect(solar.getLunar().getDay()).toBe(23); }); test('test028', () => { const solar = Solar.fromYmd(1990, 10, 8); expect(solar.getLunar().getMonthInGanZhiExact()).toBe('乙酉'); }); test('test029', () => { const solar = Solar.fromYmd(1990, 10, 9); expect(solar.getLunar().getMonthInGanZhiExact()).toBe('丙戌'); }); test('test030', () => { const solar = Solar.fromYmd(1990, 10, 8); expect(solar.getLunar().getMonthInGanZhi()).toBe('丙戌'); }); test('test031', () => { const solar = Solar.fromYmdHms(1987, 4, 17, 9, 0, 0); expect(solar.getLunar().toString()).toBe('一九八七年三月二十'); }); test('test032', () => { const lunar = Lunar.fromYmd(2034, 1, 1); expect(lunar.getSolar().toString()).toBe('2034-02-19'); }); test('test033', () => { const lunar = Lunar.fromYmd(2033, 12, 1); expect(lunar.getSolar().toString()).toBe('2034-01-20'); }); test('test034', () => { const lunar = Lunar.fromYmd(37, -12, 1); expect(lunar.getMonthInChinese()).toBe('闰腊'); }); test('test035', () => { let lunar = Lunar.fromYmd(56, -12, 1); expect(lunar.getMonthInChinese()).toBe('闰腊'); lunar = Lunar.fromYmd(75, -11, 1); expect(lunar.getMonthInChinese()).toBe('闰冬'); lunar = Lunar.fromYmd(94, -11, 1); expect(lunar.getMonthInChinese()).toBe('闰冬'); lunar = Lunar.fromYmd(94, 12, 1); expect(lunar.getMonthInChinese()).toBe('腊'); lunar = Lunar.fromYmd(113, 12, 1); expect(lunar.getMonthInChinese()).toBe('腊'); lunar = Lunar.fromYmd(113, -12, 1); expect(lunar.getMonthInChinese()).toBe('闰腊'); lunar = Lunar.fromYmd(5552, -12, 1); expect(lunar.getMonthInChinese()).toBe('闰腊'); }); test('test036', () => { const solar = Solar.fromYmd(5553, 1, 22); expect(solar.getLunar().toString()).toBe('五五五二年闰腊月初二'); }); test('test037', () => { const solar = Solar.fromYmd(7013, 12, 24); expect(solar.getLunar().toString()).toBe('七〇一三年闰冬月初四'); }); test('test038', () => { const lunar = Lunar.fromYmd(7013, -11, 4); expect(lunar.getSolar().toString()).toBe('7013-12-24'); }); test('test041', () => { const solar = Solar.fromYmd(4, 2, 10); expect(solar.getLunar().getYearShengXiao()).toBe('鼠'); }); test('test042', () => { const solar = Solar.fromYmd(4, 2, 9); expect(solar.getLunar().getYearShengXiao()).toBe('猪'); }); test('test043', () => { const solar = Solar.fromYmd(1, 2, 12); expect(solar.getLunar().getYearShengXiao()).toBe('鸡'); }); test('test044', () => { const solar = Solar.fromYmd(1, 1, 1); expect(solar.getLunar().getYearShengXiao()).toBe('猴'); }); test('test045', () => { const lunarMonth = LunarYear.fromYear(2020).getMonth(-4); expect(lunarMonth.toString()).toBe('2020年闰四月(29)天'); }); test('test046', () => { const solar = Solar.fromYmdHms(2000, 1, 1, 16, 0, 0); expect(solar.getLunar().getHour()).toBe(16); }); test('test047', () => { const lunar = Solar.fromYmd(2017, 2, 15).getLunar(); expect(lunar.getDayLu()).toBe('子命互禄 辛命进禄'); });