UNPKG

lunar-typescript-optimize

Version:

A TypeScript library for Solar and Chinese Lunar calendar calculations, with optimized build and browser compatibility

35 lines (34 loc) 680 B
import { SolarMonth } from "./SolarMonth.mjs"; export class SolarYear { _year; static fromYear(year) { return new SolarYear(year); } static fromDate(date) { return SolarYear.fromYear(date.getFullYear()); } constructor(year) { this._year = year; } getYear() { return this._year; } next(years) { return SolarYear.fromYear(this._year + years); } getMonths() { const l = []; const m = SolarMonth.fromYm(this._year, 1); l.push(m); for (let i = 1; i < 12; i++) { l.push(m.next(i)); } return l; } toString() { return `${this.getYear()}`; } toFullString() { return `${this.getYear()}\u5E74`; } }