@drewsonne/maya-dates
Version:
Typescript package to manipulate dates in the Maya Calendar
106 lines • 4.63 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 full_date_1 = __importDefault(require("../full-date"));
var julian_1 = __importDefault(require("./western/julian"));
var distance_number_1 = __importDefault(require("./distance-number"));
var lord_of_night_1 = require("./night/lord-of-night");
var correlation_constant_1 = require("./correlation-constant");
var calendar_round_1 = require("../cr/calendar-round");
var longcount_addition_1 = __importDefault(require("../operations/longcount-addition"));
var longcount_subtraction_1 = __importDefault(require("../operations/longcount-subtraction"));
var gregorian_1 = __importDefault(require("./western/gregorian"));
var LongCount = (function (_super) {
__extends(LongCount, _super);
function LongCount() {
var cycles = [];
for (var _i = 0; _i < arguments.length; _i++) {
cycles[_i] = arguments[_i];
}
var _this = _super.apply(this, cycles) || this;
_this.correlationConstant = (0, correlation_constant_1.getCorrelationConstant)(584283);
return _this;
}
LongCount.fromDistanceNumber = function (dn) {
return new (LongCount.bind.apply(LongCount, __spreadArray([void 0], dn.parts, false)))();
};
LongCount.prototype.setCorrelationConstant = function (newConstant) {
this.correlationConstant = newConstant;
return this;
};
Object.defineProperty(LongCount.prototype, "julianDay", {
get: function () {
return this.correlationConstant.value + this.getPosition();
},
enumerable: false,
configurable: true
});
Object.defineProperty(LongCount.prototype, "gregorian", {
get: function () {
return new gregorian_1.default(this.julianDay);
},
enumerable: false,
configurable: true
});
Object.defineProperty(LongCount.prototype, "julian", {
get: function () {
return new julian_1.default(this.julianDay);
},
enumerable: false,
configurable: true
});
LongCount.prototype.clone = function () {
return new (LongCount.bind.apply(LongCount, __spreadArray([void 0], this.parts, false)))();
};
Object.defineProperty(LongCount.prototype, "lordOfNight", {
get: function () {
return lord_of_night_1.lords.get("G".concat(((this.getPosition() - 1) % 9) + 1));
},
enumerable: false,
configurable: true
});
LongCount.prototype.buildCalendarRound = function () {
return calendar_round_1.origin.shift(this.getPosition());
};
LongCount.prototype.buildFullDate = function () {
return new full_date_1.default(this.buildCalendarRound(), this.clone());
};
LongCount.prototype.plus = function (newLc) {
return new longcount_addition_1.default(LongCount, this, newLc);
};
LongCount.prototype.minus = function (newLc) {
return new longcount_subtraction_1.default(LongCount, this, newLc);
};
LongCount.prototype.asDistanceNumber = function () {
return new (distance_number_1.default.bind.apply(distance_number_1.default, __spreadArray([void 0], this.parts, false)))();
};
return LongCount;
}(distance_number_1.default));
exports.default = LongCount;
//# sourceMappingURL=long-count.js.map