@drewsonne/maya-dates
Version:
Typescript package to manipulate dates in the Maya Calendar
77 lines • 3.2 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 __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
if (ar || !(i in from)) {
if (!ar) ar = Array.prototype.slice.call(from, 0, i);
ar[i] = from[i];
}
}
return to.concat(ar || Array.prototype.slice.call(from));
};
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
var longcount_operation_1 = __importDefault(require("./longcount-operation"));
var LongcountAddition = (function (_super) {
__extends(LongcountAddition, _super);
function LongcountAddition() {
return _super !== null && _super.apply(this, arguments) || this;
}
LongcountAddition.prototype.equals = function () {
var _a;
var _b = this.buildOperationComponents(), aParts = _b[0], bParts = _b[1], isInverted = _b[2];
var newParts = aParts.map(function (p, i) {
var bPart = bParts[i];
if (typeof p === 'number') {
if (typeof bPart === 'number') {
return p + bPart;
}
else {
throw new Error("'bPart' is not a number");
}
}
else {
throw new Error("'p' is not a number");
}
});
var carry = 0;
var i = 0;
while (i < newParts.length || carry > 0) {
newParts[i] += carry;
carry = 0;
var monthLength = (i === 1) ? 15 : 20;
if (newParts[i] >= monthLength) {
var positionValue = newParts[i] % monthLength;
carry = Math.floor(newParts[i] / monthLength);
newParts[i] = positionValue;
}
i += 1;
}
return new ((_a = this.LcClass).bind.apply(_a, __spreadArray([void 0], newParts, false)))();
};
LongcountAddition.prototype.equal = function (other) {
if (other instanceof LongcountAddition) {
return this.a.equal(other.a) && this.b.equal(other.b);
}
return false;
};
return LongcountAddition;
}(longcount_operation_1.default));
exports.default = LongcountAddition;
//# sourceMappingURL=longcount-addition.js.map