tyme4ts
Version:
Tyme是一个非常强大的日历工具库,可以看作 Lunar 的升级版,拥有更优的设计和扩展性,支持公历和农历、星座、干支、生肖、节气、法定假日等。
51 lines (42 loc) • 1.15 kB
text/typescript
import {suite, test} from '@testdeck/mocha';
import {SolarDay, SolarFestival} from '../lib';
import {equal, ifError, ok} from 'assert';
class SolarFestivalTest {
test2() {
const f = SolarFestival.fromIndex(2023, 0);
ok(f);
const f1 = f.next(13);
ok(f1);
equal(f1.toString(), '2024年5月1日 五一劳动节');
const f2 = f.next(-3);
ok(f2);
equal(f2.toString(), '2022年8月1日 八一建军节');
}
test3() {
const f = SolarFestival.fromIndex(2023, 0);
ok(f);
const f1 = f.next(-9);
ok(f1);
equal(f1.toString(), '2022年3月8日 三八妇女节');
}
test4() {
const f = SolarDay.fromYmd(2010, 1, 1).getFestival();
ok(f);
equal(f.toString(), '2010年1月1日 元旦');
}
test5() {
const f = SolarDay.fromYmd(2021, 5, 4).getFestival();
ok(f);
equal(f.toString(), '2021年5月4日 五四青年节');
}
test6() {
const f = SolarDay.fromYmd(1939, 5, 4).getFestival();
ifError(f);
}
}