UNPKG

@iro/calendar

Version:

lunar is a calendar library for Solar and Chinese Lunar.

44 lines 1.61 kB
import { SolarMonth } from './SolarMonth'; var SolarHalfYear = (function () { function SolarHalfYear(year, month) { this._year = year; this._month = month; } SolarHalfYear.fromYm = function (year, month) { return new SolarHalfYear(year, month); }; SolarHalfYear.fromDate = function (date) { return SolarHalfYear.fromYm(date.getFullYear(), date.getMonth() + 1); }; SolarHalfYear.prototype.getYear = function () { return this._year; }; SolarHalfYear.prototype.getMonth = function () { return this._month; }; SolarHalfYear.prototype.getIndex = function () { return Math.ceil(this._month / 6); }; SolarHalfYear.prototype.next = function (halfYears) { var month = SolarMonth.fromYm(this._year, this._month).next(6 * halfYears); return SolarHalfYear.fromYm(month.getYear(), month.getMonth()); }; SolarHalfYear.prototype.getMonths = function () { var l = []; var index = this.getIndex() - 1; for (var i = 0; i < 6; i++) { l.push(SolarMonth.fromYm(this._year, 6 * index + i + 1)); } return l; }; SolarHalfYear.prototype.toString = function () { return "".concat(this.getYear(), ".").concat(this.getIndex()); }; SolarHalfYear.prototype.toFullString = function () { var name = ['上', '下'][this.getIndex() - 1]; return "".concat(this.getYear(), "\u5E74").concat(name, "\u534A\u5E74"); }; return SolarHalfYear; }()); export { SolarHalfYear }; //# sourceMappingURL=SolarHalfYear.js.map