UNPKG

@phensley/cldr-core

Version:
52 lines 2.14 kB
"use strict"; var __extends = (this && this.__extends) || (function () { var extendStatics = Object.setPrototypeOf || ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; return function (d, b) { extendStatics(d, b); function __() { this.constructor = d; } d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); }; })(); Object.defineProperty(exports, "__esModule", { value: true }); var gregorian_1 = require("./gregorian"); /** * A date in the Buddhist calendar. * * type: buddhist */ var BuddhistDate = /** @class */ (function (_super) { __extends(BuddhistDate, _super); function BuddhistDate(firstDay, minDays) { return _super.call(this, 'buddhist', firstDay, minDays) || this; } BuddhistDate.prototype.add = function (fields) { var zoneId = fields.zoneId || this.timeZoneId(); var _a = this._add(fields), jd = _a[0], ms = _a[1]; return new BuddhistDate(this._firstDay, this._minDays).initFromJD(jd, ms, zoneId); }; BuddhistDate.prototype.toString = function () { return this._toString('Buddhist'); }; BuddhistDate.fromUnixEpoch = function (epoch, zoneId, firstDay, minDays) { return new BuddhistDate(firstDay, minDays).initFromUnixEpoch(epoch, zoneId); }; BuddhistDate.prototype.initFromUnixEpoch = function (epoch, zoneId) { _super.prototype.initFromUnixEpoch.call(this, epoch, zoneId); computeBuddhistFields(this._fields); return this; }; BuddhistDate.prototype.initFromJD = function (jd, msDay, zoneId) { _super.prototype.initFromJD.call(this, jd, msDay, zoneId); computeBuddhistFields(this._fields); return this; }; return BuddhistDate; }(gregorian_1.GregorianDate)); exports.BuddhistDate = BuddhistDate; var computeBuddhistFields = function (f) { f[2 /* ERA */] = 0; f[4 /* YEAR */] = f[3 /* EXTENDED_YEAR */] - -543 /* BUDDHIST_ERA_START */; }; //# sourceMappingURL=buddhist.js.map