tyme4ts
Version:
Tyme是一个非常强大的日历工具库,可以看作 Lunar 的升级版,拥有更优的设计和扩展性,支持公历和农历、星座、干支、生肖、节气、法定假日等。
43 lines (37 loc) • 1.16 kB
text/typescript
import {suite, test} from '@testdeck/mocha';
import {LunarDay, LunarFestival, SolarDay} from '../lib';
import {equal, ok} from 'assert';
class LunarFestivalTest {
test2() {
const f = LunarFestival.fromIndex(2023, 0);
ok(f);
equal(f.next(13).toString(), '农历甲辰年正月初一 春节');
equal(f.next(-3).toString(), '农历壬寅年十一月廿九 冬至节');
}
test3() {
const f = LunarFestival.fromIndex(2023, 0);
ok(f);
equal(f.next(-9).toString(), '农历壬寅年三月初五 清明节');
}
test4() {
const f = LunarDay.fromYmd(2010, 1, 15).getFestival();
ok(f);
equal(f.toString(), '农历庚寅年正月十五 元宵节');
}
test5() {
const f = LunarDay.fromYmd(2021, 12, 29).getFestival();
ok(f);
equal(f.toString(), '农历辛丑年十二月廿九 除夕');
}
test6() {
const f = SolarDay.fromYmd(2025, 12, 21).getLunarDay().getFestival();
ok(f);
equal(f.toString(), '农历乙巳年十一月初二 冬至节');
}
}