UNPKG

@jbouduin/holidays-lib

Version:
64 lines (63 loc) 2.66 kB
"use strict"; var __extends = (this && this.__extends) || (function () { var extendStatics = function (d, b) { extendStatics = Object.setPrototypeOf || ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; }; return extendStatics(d, b); }; return function (d, b) { if (typeof b !== "function" && b !== null) throw new TypeError("Class extends value " + String(b) + " is not a constructor or null"); extendStatics(d, b); function __() { this.constructor = d; } d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); }; })(); Object.defineProperty(exports, "__esModule", { value: true }); exports.ChristianFactory = void 0; var errors_1 = require("../errors"); var holidays_1 = require("../holidays"); var types_1 = require("../types"); var types_2 = require("../types"); var base_factory_1 = require("./base-factory"); var ChristianFactory = /** @class */ (function (_super) { __extends(ChristianFactory, _super); //#endregion //#region Constructor & C° function ChristianFactory() { var _this = _super.call(this) || this; _this.chronology = types_1.ChronologyType.GREGORIAN; return _this; } //#endregion //#region Abstract methods implementation ChristianFactory.prototype.createHoliday = function (key, category, cycle, validFrom, validTo) { return new holidays_1.ChristianHoliday(key, category, cycle, validFrom, validTo, this.chronology); }; ChristianFactory.prototype.extractData = function (obj) { if (obj.chronology) { this.chronology = types_1.ChronologyType[obj.chronology]; } else { this.chronology = types_1.ChronologyType.GREGORIAN; } if (this.chronology === undefined) { this.addError(errors_1.ErrorKey.CHRISTIAN_CHRONOLOGY_INVALID); } }; ChristianFactory.prototype.extractKey = function (obj) { var result = types_2.ChristianHolidayType[obj.key]; if (!result && result !== 0) { if (!obj.key) { this.addError(errors_1.ErrorKey.CHRISTIAN_TYPE_MISSING); } else { this.addError(errors_1.ErrorKey.CHRISTIAN_TYPE_INVALID, obj.key); } } return result; }; return ChristianFactory; }(base_factory_1.BaseFactory)); exports.ChristianFactory = ChristianFactory;