@drewsonne/maya-dates
Version:
Typescript package to manipulate dates in the Maya Calendar
48 lines • 2.42 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 base_1 = __importDefault(require("./base"));
var calendar_round_1 = require("../cr/calendar-round");
var tzolkin_1 = require("../cr/tzolkin");
var haab_1 = require("../cr/haab");
var tzolkinDay_1 = require("../cr/component/tzolkinDay");
var haabMonth_1 = require("../cr/component/haabMonth");
var coefficient_1 = require("../cr/component/coefficient");
var CalendarRoundFactory = (function (_super) {
__extends(CalendarRoundFactory, _super);
function CalendarRoundFactory() {
return _super.call(this, /([*\d]+)\s?([^\s]+)\s?([*\d]+)\s?([^\s]+)/) || this;
}
CalendarRoundFactory.prototype.parse = function (raw) {
var parts = this.split(raw);
if (parts.length < 4) {
throw new Error("Calendar Round does not have enough components");
}
var tzolkinPart = (0, tzolkin_1.getTzolkin)((0, coefficient_1.coefficientParser)(parts[0]), (0, tzolkinDay_1.getTzolkinDay)(parts[1]));
var haabPart = (0, haab_1.getHaab)((0, coefficient_1.coefficientParser)(parts[2]), (0, haabMonth_1.getHaabMonth)(parts[3]));
return (0, calendar_round_1.getCalendarRound)(tzolkinPart, haabPart);
};
CalendarRoundFactory.prototype.isNumberString = function (potentialNumber) {
return potentialNumber.match(/^\d+$/g) !== null;
};
return CalendarRoundFactory;
}(base_1.default));
exports.default = CalendarRoundFactory;
//# sourceMappingURL=calendar-round.js.map