@drewsonne/maya-dates
Version:
Typescript package to manipulate dates in the Maya Calendar
63 lines • 2.79 kB
JavaScript
;
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 __());
};
})();
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
var full_date_1 = __importDefault(require("../full-date"));
var longcount_wildcard_1 = __importDefault(require("./longcount-wildcard"));
var comment_wrapper_1 = require("../comment-wrapper");
var FullDateWildcard = (function (_super) {
__extends(FullDateWildcard, _super);
function FullDateWildcard(partialDate) {
var _this = _super.call(this) || this;
_this.fullDate = partialDate;
return _this;
}
FullDateWildcard.prototype.equal = function (other) {
if (other instanceof FullDateWildcard) {
return this.fullDate.equal(other.fullDate);
}
return false;
};
FullDateWildcard.prototype.run = function () {
var _this = this;
if (!this.fullDate.isPartial()) {
return [this.fullDate];
}
if (this.fullDate.lc.isPartial()) {
var isPartialCr_1 = this.fullDate.cr.isPartial();
var fullDatesFromPartialLc = new longcount_wildcard_1.default(this.fullDate.lc)
.run()
.map(function (potentialLc) { return potentialLc.buildFullDate(); });
var that = this;
return fullDatesFromPartialLc.filter(function (fullDate) {
return isPartialCr_1 ? fullDate.cr.match(_this.fullDate.cr) : (fullDate.cr === _this.fullDate.cr);
}, this);
}
var staticCr = this.fullDate.lc.buildCalendarRound();
return (staticCr.match(this.fullDate.cr))
? [new full_date_1.default(staticCr, this.fullDate.lc)]
: [];
};
FullDateWildcard.prototype.toString = function () {
return this.fullDate.toString();
};
return FullDateWildcard;
}(comment_wrapper_1.CommentWrapper));
exports.default = FullDateWildcard;
//# sourceMappingURL=fulldate-wildcard.js.map