UNPKG

@iro/calendar

Version:

lunar is a calendar library for Solar and Chinese Lunar.

43 lines 1.52 kB
import { SolarMonth } from './SolarMonth'; var SolarSeason = (function () { function SolarSeason(year, month) { this._year = year; this._month = month; } SolarSeason.fromYm = function (year, month) { return new SolarSeason(year, month); }; SolarSeason.fromDate = function (date) { return SolarSeason.fromYm(date.getFullYear(), date.getMonth() + 1); }; SolarSeason.prototype.getYear = function () { return this._year; }; SolarSeason.prototype.getMonth = function () { return this._month; }; SolarSeason.prototype.getIndex = function () { return Math.ceil(this._month / 3); }; SolarSeason.prototype.next = function (seasons) { var month = SolarMonth.fromYm(this._year, this._month).next(3 * seasons); return SolarSeason.fromYm(month.getYear(), month.getMonth()); }; SolarSeason.prototype.getMonths = function () { var l = []; var index = this.getIndex() - 1; for (var i = 0; i < 3; i++) { l.push(SolarMonth.fromYm(this._year, 3 * index + i + 1)); } return l; }; SolarSeason.prototype.toString = function () { return "".concat(this.getYear(), ".").concat(this.getIndex()); }; SolarSeason.prototype.toFullString = function () { return "".concat(this.getYear(), "\u5E74").concat(this.getIndex(), "\u5B63\u5EA6"); }; return SolarSeason; }()); export { SolarSeason }; //# sourceMappingURL=SolarSeason.js.map