UNPKG

@js-joda/core

Version:

a date and time library for javascript

1,276 lines (1,253 loc) 397 kB
//! @version @js-joda/core - 6.1.0 //! @copyright (c) 2015-present, Philipp Thürwächter, Pattrick Hüper & js-joda contributors //! @copyright (c) 2007-present, Stephen Colebourne & Michael Nascimento Santos //! @license BSD-3-Clause (see LICENSE in the root directory of this source tree) /** * @copyright (c) 2016, Philipp Thürwächter & Pattrick Hüper * @license BSD-3-Clause (see LICENSE in the root directory of this source tree) */ function createErrorType(name, init, superErrorClass) { if (superErrorClass === void 0) { superErrorClass = Error; } function JsJodaException(message) { if (!Error.captureStackTrace) { this.stack = new Error().stack; } else { Error.captureStackTrace(this, this.constructor); } this.message = message; init && init.apply(this, arguments); this.toString = function () { return this.name + ": " + this.message; }; } JsJodaException.prototype = Object.create(superErrorClass.prototype); JsJodaException.prototype.name = name; JsJodaException.prototype.constructor = JsJodaException; return JsJodaException; } var DateTimeException = createErrorType('DateTimeException', messageWithCause); var DateTimeParseException = createErrorType('DateTimeParseException', messageForDateTimeParseException); var UnsupportedTemporalTypeException = createErrorType('UnsupportedTemporalTypeException', null, DateTimeException); var ArithmeticException = createErrorType('ArithmeticException'); var IllegalArgumentException = createErrorType('IllegalArgumentException'); var IllegalStateException = createErrorType('IllegalStateException'); var NullPointerException = createErrorType('NullPointerException'); function messageWithCause(message, cause) { if (cause === void 0) { cause = null; } var msg = message || this.name; if (cause !== null && cause instanceof Error) { msg += "\n-------\nCaused by: " + cause.stack + "\n-------\n"; } this.message = msg; } function messageForDateTimeParseException(message, text, index, cause) { if (text === void 0) { text = ''; } if (index === void 0) { index = 0; } if (cause === void 0) { cause = null; } var msg = message || this.name; msg += ": " + text + ", at index: " + index; if (cause !== null && cause instanceof Error) { msg += "\n-------\nCaused by: " + cause.stack + "\n-------\n"; } this.message = msg; this.parsedString = function () { return text; }; this.errorIndex = function () { return index; }; } function _assertThisInitialized(e) { if (void 0 === e) throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); return e; } function _inheritsLoose(t, o) { t.prototype = Object.create(o.prototype), t.prototype.constructor = t, _setPrototypeOf(t, o); } function _setPrototypeOf(t, e) { return _setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function (t, e) { return t.__proto__ = e, t; }, _setPrototypeOf(t, e); } /** * @copyright (c) 2016, Philipp Thürwächter & Pattrick Hüper * @license BSD-3-Clause (see LICENSE in the root directory of this source tree) */ function assert(assertion, msg, error) { if (!assertion) { if (error) { throw new error(msg); } else { throw new Error(msg); } } } function requireNonNull(value, parameterName) { if (value == null) { throw new NullPointerException(parameterName + " must not be null"); } return value; } function requireInstance(value, _class, parameterName) { if (!(value instanceof _class)) { throw new IllegalArgumentException(parameterName + " must be an instance of " + (_class.name ? _class.name : _class) + (value && value.constructor && value.constructor.name ? ", but is " + value.constructor.name : '')); } return value; } function abstractMethodFail(methodName) { throw new TypeError("abstract method \"" + methodName + "\" is not implemented"); } var assert$1 = /*#__PURE__*/Object.freeze({ __proto__: null, abstractMethodFail: abstractMethodFail, assert: assert, requireInstance: requireInstance, requireNonNull: requireNonNull }); /** * @copyright (c) 2016, Philipp Thürwächter & Pattrick Hüper * @copyright (c) 2007-present, Stephen Colebourne & Michael Nascimento Santos * @license BSD-3-Clause (see LICENSE in the root directory of this source tree) */ var MAX_SAFE_INTEGER = 9007199254740991; var MIN_SAFE_INTEGER = -9007199254740991; var MathUtil = function () { function MathUtil() {} MathUtil.intDiv = function intDiv(x, y) { var r = x / y; r = MathUtil.roundDown(r); return MathUtil.safeZero(r); }; MathUtil.intMod = function intMod(x, y) { var r = x - MathUtil.intDiv(x, y) * y; r = MathUtil.roundDown(r); return MathUtil.safeZero(r); }; MathUtil.roundDown = function roundDown(r) { if (r < 0) { return Math.ceil(r); } else { return Math.floor(r); } }; MathUtil.floorDiv = function floorDiv(x, y) { var r = Math.floor(x / y); return MathUtil.safeZero(r); }; MathUtil.floorMod = function floorMod(x, y) { var r = x - MathUtil.floorDiv(x, y) * y; return MathUtil.safeZero(r); }; MathUtil.safeAdd = function safeAdd(x, y) { MathUtil.verifyInt(x); MathUtil.verifyInt(y); if (x === 0) { return MathUtil.safeZero(y); } if (y === 0) { return MathUtil.safeZero(x); } var r = MathUtil.safeToInt(x + y); if (r === x || r === y) { throw new ArithmeticException('Invalid addition beyond MAX_SAFE_INTEGER!'); } return r; }; MathUtil.safeSubtract = function safeSubtract(x, y) { MathUtil.verifyInt(x); MathUtil.verifyInt(y); if (x === 0 && y === 0) { return 0; } else if (x === 0) { return MathUtil.safeZero(-1 * y); } else if (y === 0) { return MathUtil.safeZero(x); } return MathUtil.safeToInt(x - y); }; MathUtil.safeMultiply = function safeMultiply(x, y) { MathUtil.verifyInt(x); MathUtil.verifyInt(y); if (x === 1) { return MathUtil.safeZero(y); } if (y === 1) { return MathUtil.safeZero(x); } if (x === 0 || y === 0) { return 0; } var r = MathUtil.safeToInt(x * y); if (r / y !== x || x === MIN_SAFE_INTEGER && y === -1 || y === MIN_SAFE_INTEGER && x === -1) { throw new ArithmeticException("Multiplication overflows: " + x + " * " + y); } return r; }; MathUtil.parseInt = function (value) { var r = parseInt(value); return MathUtil.safeToInt(r); }; MathUtil.safeToInt = function safeToInt(value) { MathUtil.verifyInt(value); return MathUtil.safeZero(value); }; MathUtil.verifyInt = function verifyInt(value) { if (value == null) { throw new ArithmeticException("Invalid value: '" + value + "', using null or undefined as argument"); } if (isNaN(value)) { throw new ArithmeticException('Invalid int value, using NaN as argument'); } if (!Number.isInteger(Number(value))) { throw new ArithmeticException("Invalid value: '" + value + "' is a float"); } if (value > MAX_SAFE_INTEGER || value < MIN_SAFE_INTEGER) { throw new ArithmeticException("Calculation overflows an int: " + value); } }; MathUtil.safeZero = function safeZero(value) { return value === 0 ? 0 : +value; }; MathUtil.compareNumbers = function compareNumbers(a, b) { if (a < b) { return -1; } if (a > b) { return 1; } return 0; }; MathUtil.smi = function smi(int) { return int >>> 1 & 0x40000000 | int & 0xBFFFFFFF; }; MathUtil.hash = function hash(number) { if (number !== number || number === Infinity) { return 0; } var result = number; while (number > 0xFFFFFFFF) { number /= 0xFFFFFFFF; result ^= number; } return MathUtil.smi(result); }; MathUtil.hashCode = function hashCode() { var result = 17; for (var _len = arguments.length, numbers = new Array(_len), _key = 0; _key < _len; _key++) { numbers[_key] = arguments[_key]; } for (var _i = 0, _numbers = numbers; _i < _numbers.length; _i++) { var n = _numbers[_i]; result = (result << 5) - result + MathUtil.hash(n); } return MathUtil.hash(result); }; return MathUtil; }(); MathUtil.MAX_SAFE_INTEGER = MAX_SAFE_INTEGER; MathUtil.MIN_SAFE_INTEGER = MIN_SAFE_INTEGER; /** * @copyright (c) 2016, Philipp Thürwächter & Pattrick Hüper * @license BSD-3-Clause (see LICENSE in the root directory of this source tree) */var Enum = function () { function Enum(name) { this._name = name; } var _proto = Enum.prototype; _proto.equals = function equals(other) { return this === other; }; _proto.toString = function toString() { return this._name; }; _proto.toJSON = function toJSON() { return this.toString(); }; return Enum; }(); /* * @copyright (c) 2016, Philipp Thürwächter & Pattrick Hüper * @copyright (c) 2007-present, Stephen Colebourne & Michael Nascimento Santos * @license BSD-3-Clause (see LICENSE in the root directory of this source tree) */ var TemporalAmount = function () { function TemporalAmount() {} var _proto = TemporalAmount.prototype; _proto.get = function get(unit) { abstractMethodFail('get'); }; _proto.units = function units() { abstractMethodFail('units'); }; _proto.addTo = function addTo(temporal) { abstractMethodFail('addTo'); }; _proto.subtractFrom = function subtractFrom(temporal) { abstractMethodFail('subtractFrom'); }; return TemporalAmount; }(); if (typeof Symbol !== 'undefined' && Symbol.toPrimitive) { TemporalAmount.prototype[Symbol.toPrimitive] = function (hint) { if (hint !== 'number') { return this.toString(); } throw new TypeError('A conversion from TemporalAmount to a number is not allowed. ' + 'To compare use the methods .equals(), .compareTo(), .isBefore() ' + 'or one that is more suitable to your use case.'); }; } /* * @copyright (c) 2016, Philipp Thürwächter & Pattrick Hüper * @copyright (c) 2007-present, Stephen Colebourne & Michael Nascimento Santos * @license BSD-3-Clause (see LICENSE in the root directory of this source tree) */ var TemporalUnit = function () { function TemporalUnit() {} var _proto = TemporalUnit.prototype; _proto.duration = function duration() { abstractMethodFail('duration'); }; _proto.isDurationEstimated = function isDurationEstimated() { abstractMethodFail('isDurationEstimated'); }; _proto.isDateBased = function isDateBased() { abstractMethodFail('isDateBased'); }; _proto.isTimeBased = function isTimeBased() { abstractMethodFail('isTimeBased'); }; _proto.isSupportedBy = function isSupportedBy(temporal) { abstractMethodFail('isSupportedBy'); }; _proto.addTo = function addTo(dateTime, periodToAdd) { abstractMethodFail('addTo'); }; _proto.between = function between(temporal1, temporal2) { abstractMethodFail('between'); }; return TemporalUnit; }(); var Duration = function (_TemporalAmount) { function Duration(seconds, nanos) { var _this; _this = _TemporalAmount.call(this) || this; _this._seconds = MathUtil.safeToInt(seconds); _this._nanos = MathUtil.safeToInt(nanos); return _this; } _inheritsLoose(Duration, _TemporalAmount); Duration.ofDays = function ofDays(days) { return Duration._create(MathUtil.safeMultiply(days, LocalTime.SECONDS_PER_DAY), 0); }; Duration.ofHours = function ofHours(hours) { return Duration._create(MathUtil.safeMultiply(hours, LocalTime.SECONDS_PER_HOUR), 0); }; Duration.ofMinutes = function ofMinutes(minutes) { return Duration._create(MathUtil.safeMultiply(minutes, LocalTime.SECONDS_PER_MINUTE), 0); }; Duration.ofSeconds = function ofSeconds(seconds, nanoAdjustment) { if (nanoAdjustment === void 0) { nanoAdjustment = 0; } var secs = MathUtil.safeAdd(seconds, MathUtil.floorDiv(nanoAdjustment, LocalTime.NANOS_PER_SECOND)); var nos = MathUtil.floorMod(nanoAdjustment, LocalTime.NANOS_PER_SECOND); return Duration._create(secs, nos); }; Duration.ofMillis = function ofMillis(millis) { var secs = MathUtil.intDiv(millis, 1000); var mos = MathUtil.intMod(millis, 1000); if (mos < 0) { mos += 1000; secs--; } return Duration._create(secs, mos * 1000000); }; Duration.ofNanos = function ofNanos(nanos) { var secs = MathUtil.intDiv(nanos, LocalTime.NANOS_PER_SECOND); var nos = MathUtil.intMod(nanos, LocalTime.NANOS_PER_SECOND); if (nos < 0) { nos += LocalTime.NANOS_PER_SECOND; secs--; } return this._create(secs, nos); }; Duration.of = function of(amount, unit) { return Duration.ZERO.plus(amount, unit); }; Duration.from = function from(amount) { requireNonNull(amount, 'amount'); requireInstance(amount, TemporalAmount); var duration = Duration.ZERO; amount.units().forEach(function (unit) { duration = duration.plus(amount.get(unit), unit); }); return duration; }; Duration.between = function between(startInclusive, endExclusive) { requireNonNull(startInclusive, 'startInclusive'); requireNonNull(endExclusive, 'endExclusive'); var secs = startInclusive.until(endExclusive, ChronoUnit.SECONDS); var nanos = 0; if (startInclusive.isSupported(ChronoField.NANO_OF_SECOND) && endExclusive.isSupported(ChronoField.NANO_OF_SECOND)) { try { var startNos = startInclusive.getLong(ChronoField.NANO_OF_SECOND); nanos = endExclusive.getLong(ChronoField.NANO_OF_SECOND) - startNos; if (secs > 0 && nanos < 0) { nanos += LocalTime.NANOS_PER_SECOND; } else if (secs < 0 && nanos > 0) { nanos -= LocalTime.NANOS_PER_SECOND; } else if (secs === 0 && nanos !== 0) { var adjustedEnd = endExclusive.with(ChronoField.NANO_OF_SECOND, startNos); secs = startInclusive.until(adjustedEnd, ChronoUnit.SECONDS); } } catch (e) {} } return this.ofSeconds(secs, nanos); }; Duration.parse = function parse(text) { requireNonNull(text, 'text'); var PATTERN = new RegExp('([-+]?)P(?:([-+]?[0-9]+)D)?(T(?:([-+]?[0-9]+)H)?(?:([-+]?[0-9]+)M)?(?:([-+]?[0-9]+)(?:[.,]([0-9]{0,9}))?S)?)?', 'i'); var matches = PATTERN.exec(text); if (matches !== null) { if ('T' === matches[3] === false) { var negate = '-' === matches[1]; var dayMatch = matches[2]; var hourMatch = matches[4]; var minuteMatch = matches[5]; var secondMatch = matches[6]; var fractionMatch = matches[7]; if (dayMatch != null || hourMatch != null || minuteMatch != null || secondMatch != null) { var daysAsSecs = Duration._parseNumber(text, dayMatch, LocalTime.SECONDS_PER_DAY, 'days'); var hoursAsSecs = Duration._parseNumber(text, hourMatch, LocalTime.SECONDS_PER_HOUR, 'hours'); var minsAsSecs = Duration._parseNumber(text, minuteMatch, LocalTime.SECONDS_PER_MINUTE, 'minutes'); var seconds = Duration._parseNumber(text, secondMatch, 1, 'seconds'); var negativeSecs = secondMatch != null && secondMatch.charAt(0) === '-'; var nanos = Duration._parseFraction(text, fractionMatch, negativeSecs ? -1 : 1); try { return Duration._create(negate, daysAsSecs, hoursAsSecs, minsAsSecs, seconds, nanos); } catch (ex) { throw new DateTimeParseException('Text cannot be parsed to a Duration: overflow', text, 0, ex); } } } } throw new DateTimeParseException('Text cannot be parsed to a Duration', text, 0); }; Duration._parseNumber = function _parseNumber(text, parsed, multiplier, errorText) { if (parsed == null) { return 0; } try { if (parsed[0] === '+') { parsed = parsed.substring(1); } return MathUtil.safeMultiply(parseFloat(parsed), multiplier); } catch (ex) { throw new DateTimeParseException("Text cannot be parsed to a Duration: " + errorText, text, 0, ex); } }; Duration._parseFraction = function _parseFraction(text, parsed, negate) { if (parsed == null || parsed.length === 0) { return 0; } parsed = (parsed + "000000000").substring(0, 9); return parseFloat(parsed) * negate; }; Duration._create = function _create() { if (arguments.length <= 2) { return Duration._createSecondsNanos(arguments[0], arguments[1]); } else { return Duration._createNegateDaysHoursMinutesSecondsNanos(arguments[0], arguments[1], arguments[2], arguments[3], arguments[4], arguments[5]); } }; Duration._createNegateDaysHoursMinutesSecondsNanos = function _createNegateDaysHoursMinutesSecondsNanos(negate, daysAsSecs, hoursAsSecs, minsAsSecs, secs, nanos) { var seconds = MathUtil.safeAdd(daysAsSecs, MathUtil.safeAdd(hoursAsSecs, MathUtil.safeAdd(minsAsSecs, secs))); if (negate) { return Duration.ofSeconds(seconds, nanos).negated(); } return Duration.ofSeconds(seconds, nanos); }; Duration._createSecondsNanos = function _createSecondsNanos(seconds, nanoAdjustment) { if (seconds === void 0) { seconds = 0; } if (nanoAdjustment === void 0) { nanoAdjustment = 0; } if (seconds === 0 && nanoAdjustment === 0) { return Duration.ZERO; } return new Duration(seconds, nanoAdjustment); }; var _proto = Duration.prototype; _proto.get = function get(unit) { if (unit === ChronoUnit.SECONDS) { return this._seconds; } else if (unit === ChronoUnit.NANOS) { return this._nanos; } else { throw new UnsupportedTemporalTypeException("Unsupported unit: " + unit); } }; _proto.units = function units() { return [ChronoUnit.SECONDS, ChronoUnit.NANOS]; }; _proto.isZero = function isZero() { return this._seconds === 0 && this._nanos === 0; }; _proto.isNegative = function isNegative() { return this._seconds < 0; }; _proto.seconds = function seconds() { return this._seconds; }; _proto.nano = function nano() { return this._nanos; }; _proto.withSeconds = function withSeconds(seconds) { return Duration._create(seconds, this._nanos); }; _proto.withNanos = function withNanos(nanoOfSecond) { ChronoField.NANO_OF_SECOND.checkValidIntValue(nanoOfSecond); return Duration._create(this._seconds, nanoOfSecond); }; _proto.plusDuration = function plusDuration(duration) { requireNonNull(duration, 'duration'); return this.plus(duration.seconds(), duration.nano()); }; _proto.plus = function plus(durationOrNumber, unitOrNumber) { if (arguments.length === 1) { return this.plusDuration(durationOrNumber); } else if (arguments.length === 2 && unitOrNumber instanceof TemporalUnit) { return this.plusAmountUnit(durationOrNumber, unitOrNumber); } else { return this.plusSecondsNanos(durationOrNumber, unitOrNumber); } }; _proto.plusAmountUnit = function plusAmountUnit(amountToAdd, unit) { requireNonNull(amountToAdd, 'amountToAdd'); requireNonNull(unit, 'unit'); if (unit === ChronoUnit.DAYS) { return this.plusSecondsNanos(MathUtil.safeMultiply(amountToAdd, LocalTime.SECONDS_PER_DAY), 0); } if (unit.isDurationEstimated()) { throw new UnsupportedTemporalTypeException('Unit must not have an estimated duration'); } if (amountToAdd === 0) { return this; } if (unit instanceof ChronoUnit) { switch (unit) { case ChronoUnit.NANOS: return this.plusNanos(amountToAdd); case ChronoUnit.MICROS: return this.plusSecondsNanos(MathUtil.intDiv(amountToAdd, 1000000 * 1000) * 1000, MathUtil.intMod(amountToAdd, 1000000 * 1000) * 1000); case ChronoUnit.MILLIS: return this.plusMillis(amountToAdd); case ChronoUnit.SECONDS: return this.plusSeconds(amountToAdd); } return this.plusSecondsNanos(MathUtil.safeMultiply(unit.duration().seconds(), amountToAdd), 0); } var duration = unit.duration().multipliedBy(amountToAdd); return this.plusSecondsNanos(duration.seconds(), duration.nano()); }; _proto.plusDays = function plusDays(daysToAdd) { return this.plusSecondsNanos(MathUtil.safeMultiply(daysToAdd, LocalTime.SECONDS_PER_DAY), 0); }; _proto.plusHours = function plusHours(hoursToAdd) { return this.plusSecondsNanos(MathUtil.safeMultiply(hoursToAdd, LocalTime.SECONDS_PER_HOUR), 0); }; _proto.plusMinutes = function plusMinutes(minutesToAdd) { return this.plusSecondsNanos(MathUtil.safeMultiply(minutesToAdd, LocalTime.SECONDS_PER_MINUTE), 0); }; _proto.plusSeconds = function plusSeconds(secondsToAdd) { return this.plusSecondsNanos(secondsToAdd, 0); }; _proto.plusMillis = function plusMillis(millisToAdd) { return this.plusSecondsNanos(MathUtil.intDiv(millisToAdd, 1000), MathUtil.intMod(millisToAdd, 1000) * 1000000); }; _proto.plusNanos = function plusNanos(nanosToAdd) { return this.plusSecondsNanos(0, nanosToAdd); }; _proto.plusSecondsNanos = function plusSecondsNanos(secondsToAdd, nanosToAdd) { requireNonNull(secondsToAdd, 'secondsToAdd'); requireNonNull(nanosToAdd, 'nanosToAdd'); if (secondsToAdd === 0 && nanosToAdd === 0) { return this; } var epochSec = MathUtil.safeAdd(this._seconds, secondsToAdd); epochSec = MathUtil.safeAdd(epochSec, MathUtil.intDiv(nanosToAdd, LocalTime.NANOS_PER_SECOND)); nanosToAdd = MathUtil.intMod(nanosToAdd, LocalTime.NANOS_PER_SECOND); var nanoAdjustment = MathUtil.safeAdd(this._nanos, nanosToAdd); return Duration.ofSeconds(epochSec, nanoAdjustment); }; _proto.minus = function minus(durationOrNumber, unit) { if (arguments.length === 1) { return this.minusDuration(durationOrNumber); } else { return this.minusAmountUnit(durationOrNumber, unit); } }; _proto.minusDuration = function minusDuration(duration) { requireNonNull(duration, 'duration'); var secsToSubtract = duration.seconds(); var nanosToSubtract = duration.nano(); if (secsToSubtract === MIN_SAFE_INTEGER) { return this.plus(MAX_SAFE_INTEGER, -nanosToSubtract); } return this.plus(-secsToSubtract, -nanosToSubtract); }; _proto.minusAmountUnit = function minusAmountUnit(amountToSubtract, unit) { requireNonNull(amountToSubtract, 'amountToSubtract'); requireNonNull(unit, 'unit'); return amountToSubtract === MIN_SAFE_INTEGER ? this.plusAmountUnit(MAX_SAFE_INTEGER, unit) : this.plusAmountUnit(-amountToSubtract, unit); }; _proto.minusDays = function minusDays(daysToSubtract) { return daysToSubtract === MIN_SAFE_INTEGER ? this.plusDays(MAX_SAFE_INTEGER) : this.plusDays(-daysToSubtract); }; _proto.minusHours = function minusHours(hoursToSubtract) { return hoursToSubtract === MIN_SAFE_INTEGER ? this.plusHours(MAX_SAFE_INTEGER) : this.plusHours(-hoursToSubtract); }; _proto.minusMinutes = function minusMinutes(minutesToSubtract) { return minutesToSubtract === MIN_SAFE_INTEGER ? this.plusMinutes(MAX_SAFE_INTEGER) : this.plusMinutes(-minutesToSubtract); }; _proto.minusSeconds = function minusSeconds(secondsToSubtract) { return secondsToSubtract === MIN_SAFE_INTEGER ? this.plusSeconds(MAX_SAFE_INTEGER) : this.plusSeconds(-secondsToSubtract); }; _proto.minusMillis = function minusMillis(millisToSubtract) { return millisToSubtract === MIN_SAFE_INTEGER ? this.plusMillis(MAX_SAFE_INTEGER) : this.plusMillis(-millisToSubtract); }; _proto.minusNanos = function minusNanos(nanosToSubtract) { return nanosToSubtract === MIN_SAFE_INTEGER ? this.plusNanos(MAX_SAFE_INTEGER) : this.plusNanos(-nanosToSubtract); }; _proto.multipliedBy = function multipliedBy(multiplicand) { if (multiplicand === 0) { return Duration.ZERO; } if (multiplicand === 1) { return this; } var secs = MathUtil.safeMultiply(this._seconds, multiplicand); var nos = MathUtil.safeMultiply(this._nanos, multiplicand); secs = secs + MathUtil.intDiv(nos, LocalTime.NANOS_PER_SECOND); nos = MathUtil.intMod(nos, LocalTime.NANOS_PER_SECOND); return Duration.ofSeconds(secs, nos); }; _proto.dividedBy = function dividedBy(divisor) { if (divisor === 0) { throw new ArithmeticException('Cannot divide by zero'); } if (divisor === 1) { return this; } var secs = MathUtil.intDiv(this._seconds, divisor); var secsMod = MathUtil.roundDown((this._seconds / divisor - secs) * LocalTime.NANOS_PER_SECOND); var nos = MathUtil.intDiv(this._nanos, divisor); nos = secsMod + nos; return Duration.ofSeconds(secs, nos); }; _proto.negated = function negated() { return this.multipliedBy(-1); }; _proto.abs = function abs() { return this.isNegative() ? this.negated() : this; }; _proto.addTo = function addTo(temporal) { requireNonNull(temporal, 'temporal'); if (this._seconds !== 0) { temporal = temporal.plus(this._seconds, ChronoUnit.SECONDS); } if (this._nanos !== 0) { temporal = temporal.plus(this._nanos, ChronoUnit.NANOS); } return temporal; }; _proto.subtractFrom = function subtractFrom(temporal) { requireNonNull(temporal, 'temporal'); if (this._seconds !== 0) { temporal = temporal.minus(this._seconds, ChronoUnit.SECONDS); } if (this._nanos !== 0) { temporal = temporal.minus(this._nanos, ChronoUnit.NANOS); } return temporal; }; _proto.toDays = function toDays() { return MathUtil.intDiv(this._seconds, LocalTime.SECONDS_PER_DAY); }; _proto.toHours = function toHours() { return MathUtil.intDiv(this._seconds, LocalTime.SECONDS_PER_HOUR); }; _proto.toMinutes = function toMinutes() { return MathUtil.intDiv(this._seconds, LocalTime.SECONDS_PER_MINUTE); }; _proto.toMillis = function toMillis() { var millis = Math.round(MathUtil.safeMultiply(this._seconds, 1000)); millis = MathUtil.safeAdd(millis, MathUtil.intDiv(this._nanos, 1000000)); return millis; }; _proto.toNanos = function toNanos() { var totalNanos = MathUtil.safeMultiply(this._seconds, LocalTime.NANOS_PER_SECOND); totalNanos = MathUtil.safeAdd(totalNanos, this._nanos); return totalNanos; }; _proto.toHoursPart = function toHoursPart() { return MathUtil.intMod(this.toHours(), LocalTime.HOURS_PER_DAY); }; _proto.toMinutesPart = function toMinutesPart() { return MathUtil.intMod(this.toMinutes(), LocalTime.MINUTES_PER_HOUR); }; _proto.toSecondsPart = function toSecondsPart() { return MathUtil.intMod(this._seconds, LocalTime.SECONDS_PER_MINUTE); }; _proto.toMillisPart = function toMillisPart() { return MathUtil.intDiv(this._nanos, 1000000); }; _proto.compareTo = function compareTo(otherDuration) { requireNonNull(otherDuration, 'otherDuration'); requireInstance(otherDuration, Duration, 'otherDuration'); var cmp = MathUtil.compareNumbers(this._seconds, otherDuration.seconds()); if (cmp !== 0) { return cmp; } return this._nanos - otherDuration.nano(); }; _proto.equals = function equals(otherDuration) { if (this === otherDuration) { return true; } if (otherDuration instanceof Duration) { return this.seconds() === otherDuration.seconds() && this.nano() === otherDuration.nano(); } return false; }; _proto.toString = function toString() { if (this === Duration.ZERO) { return 'PT0S'; } var negativeFraction = this._seconds < 0 && this._nanos > 0; var wholeSeconds = negativeFraction ? this._seconds + 1 : this._seconds; var fractionNanos = negativeFraction ? LocalTime.NANOS_PER_SECOND - this._nanos : this._nanos; var hours = MathUtil.intDiv(wholeSeconds, LocalTime.SECONDS_PER_HOUR); var minutes = MathUtil.intDiv(MathUtil.intMod(wholeSeconds, LocalTime.SECONDS_PER_HOUR), LocalTime.SECONDS_PER_MINUTE); var secs = MathUtil.intMod(wholeSeconds, LocalTime.SECONDS_PER_MINUTE); var rval = 'PT'; if (hours !== 0) { rval += hours + "H"; } if (minutes !== 0) { rval += minutes + "M"; } if (secs === 0 && fractionNanos === 0 && rval.length > 2) { return rval; } if (secs === 0 && negativeFraction) { rval += '-0'; } else { rval += "" + secs; } if (fractionNanos > 0) { var fraction = "" + fractionNanos; while (fraction.length < 9) { fraction = "0" + fraction; } while (fraction.charAt(fraction.length - 1) === '0') { fraction = fraction.slice(0, fraction.length - 1); } rval += "." + fraction; } rval += 'S'; return rval; }; _proto.toJSON = function toJSON() { return this.toString(); }; return Duration; }(TemporalAmount); function _init$n() { Duration.ZERO = new Duration(0, 0); } /* * @copyright (c) 2016, Philipp Thürwächter & Pattrick Hüper * @license BSD-3-Clause (see LICENSE.md in the root directory of this source tree) */var YearConstants = function YearConstants() {}; function _init$m() { YearConstants.MIN_VALUE = -999999; YearConstants.MAX_VALUE = 999999; } var ChronoUnit = function (_TemporalUnit) { function ChronoUnit(name, estimatedDuration) { var _this; _this = _TemporalUnit.call(this) || this; _this._name = name; _this._duration = estimatedDuration; return _this; } _inheritsLoose(ChronoUnit, _TemporalUnit); var _proto = ChronoUnit.prototype; _proto.duration = function duration() { return this._duration; }; _proto.isDurationEstimated = function isDurationEstimated() { return this.isDateBased() || this === ChronoUnit.FOREVER; }; _proto.isDateBased = function isDateBased() { return this.compareTo(ChronoUnit.DAYS) >= 0 && this !== ChronoUnit.FOREVER; }; _proto.isTimeBased = function isTimeBased() { return this.compareTo(ChronoUnit.DAYS) < 0; }; _proto.isSupportedBy = function isSupportedBy(temporal) { if (this === ChronoUnit.FOREVER) { return false; } try { temporal.plus(1, this); return true; } catch (e) { try { temporal.plus(-1, this); return true; } catch (e2) { return false; } } }; _proto.addTo = function addTo(temporal, amount) { return temporal.plus(amount, this); }; _proto.between = function between(temporal1, temporal2) { return temporal1.until(temporal2, this); }; _proto.toString = function toString() { return this._name; }; _proto.compareTo = function compareTo(other) { return this.duration().compareTo(other.duration()); }; return ChronoUnit; }(TemporalUnit); function _init$l() { ChronoUnit.NANOS = new ChronoUnit('Nanos', Duration.ofNanos(1)); ChronoUnit.MICROS = new ChronoUnit('Micros', Duration.ofNanos(1000)); ChronoUnit.MILLIS = new ChronoUnit('Millis', Duration.ofNanos(1000000)); ChronoUnit.SECONDS = new ChronoUnit('Seconds', Duration.ofSeconds(1)); ChronoUnit.MINUTES = new ChronoUnit('Minutes', Duration.ofSeconds(60)); ChronoUnit.HOURS = new ChronoUnit('Hours', Duration.ofSeconds(3600)); ChronoUnit.HALF_DAYS = new ChronoUnit('HalfDays', Duration.ofSeconds(43200)); ChronoUnit.DAYS = new ChronoUnit('Days', Duration.ofSeconds(86400)); ChronoUnit.WEEKS = new ChronoUnit('Weeks', Duration.ofSeconds(7 * 86400)); ChronoUnit.MONTHS = new ChronoUnit('Months', Duration.ofSeconds(31556952 / 12)); ChronoUnit.YEARS = new ChronoUnit('Years', Duration.ofSeconds(31556952)); ChronoUnit.DECADES = new ChronoUnit('Decades', Duration.ofSeconds(31556952 * 10)); ChronoUnit.CENTURIES = new ChronoUnit('Centuries', Duration.ofSeconds(31556952 * 100)); ChronoUnit.MILLENNIA = new ChronoUnit('Millennia', Duration.ofSeconds(31556952 * 1000)); ChronoUnit.ERAS = new ChronoUnit('Eras', Duration.ofSeconds(31556952 * (YearConstants.MAX_VALUE + 1))); ChronoUnit.FOREVER = new ChronoUnit('Forever', Duration.ofSeconds(MathUtil.MAX_SAFE_INTEGER, 999999999)); } /** * @copyright (c) 2016, Philipp Thürwächter & Pattrick Hüper * @copyright (c) 2007-present, Stephen Colebourne & Michael Nascimento Santos * @license BSD-3-Clause (see LICENSE in the root directory of this source tree) */ var TemporalField = function () { function TemporalField() {} var _proto = TemporalField.prototype; _proto.isDateBased = function isDateBased() { abstractMethodFail('isDateBased'); }; _proto.isTimeBased = function isTimeBased() { abstractMethodFail('isTimeBased'); }; _proto.baseUnit = function baseUnit() { abstractMethodFail('baseUnit'); }; _proto.rangeUnit = function rangeUnit() { abstractMethodFail('rangeUnit'); }; _proto.range = function range() { abstractMethodFail('range'); }; _proto.rangeRefinedBy = function rangeRefinedBy(temporal) { abstractMethodFail('rangeRefinedBy'); }; _proto.getFrom = function getFrom(temporal) { abstractMethodFail('getFrom'); }; _proto.adjustInto = function adjustInto(temporal, newValue) { abstractMethodFail('adjustInto'); }; _proto.isSupportedBy = function isSupportedBy(temporal) { abstractMethodFail('isSupportedBy'); }; _proto.displayName = function displayName() { abstractMethodFail('displayName'); }; _proto.equals = function equals(other) { abstractMethodFail('equals'); }; _proto.name = function name() { abstractMethodFail('name'); }; return TemporalField; }(); /** * @copyright (c) 2016, Philipp Thürwächter & Pattrick Hüper * @copyright (c) 2007-present, Stephen Colebourne & Michael Nascimento Santos * @license BSD-3-Clause (see LICENSE in the root directory of this source tree) */ var ValueRange = function () { function ValueRange(minSmallest, minLargest, maxSmallest, maxLargest) { assert(!(minSmallest > minLargest), "Smallest minimum value '" + minSmallest + "' must be less than largest minimum value '" + minLargest + "'", IllegalArgumentException); assert(!(maxSmallest > maxLargest), "Smallest maximum value '" + maxSmallest + "' must be less than largest maximum value '" + maxLargest + "'", IllegalArgumentException); assert(!(minLargest > maxLargest), "Minimum value '" + minLargest + "' must be less than maximum value '" + maxLargest + "'", IllegalArgumentException); this._minSmallest = minSmallest; this._minLargest = minLargest; this._maxLargest = maxLargest; this._maxSmallest = maxSmallest; } var _proto = ValueRange.prototype; _proto.isFixed = function isFixed() { return this._minSmallest === this._minLargest && this._maxSmallest === this._maxLargest; }; _proto.minimum = function minimum() { return this._minSmallest; }; _proto.largestMinimum = function largestMinimum() { return this._minLargest; }; _proto.maximum = function maximum() { return this._maxLargest; }; _proto.smallestMaximum = function smallestMaximum() { return this._maxSmallest; }; _proto.isValidValue = function isValidValue(value) { return this.minimum() <= value && value <= this.maximum(); }; _proto.checkValidValue = function checkValidValue(value, field) { var msg; if (!this.isValidValue(value)) { if (field != null) { msg = "Invalid value for " + field + " (valid values " + this.toString() + "): " + value; } else { msg = "Invalid value (valid values " + this.toString() + "): " + value; } return assert(false, msg, DateTimeException); } return value; }; _proto.checkValidIntValue = function checkValidIntValue(value, field) { if (this.isValidIntValue(value) === false) { throw new DateTimeException("Invalid int value for " + field + ": " + value); } return value; }; _proto.isValidIntValue = function isValidIntValue(value) { return this.isIntValue() && this.isValidValue(value); }; _proto.isIntValue = function isIntValue() { return this.minimum() >= MathUtil.MIN_SAFE_INTEGER && this.maximum() <= MathUtil.MAX_SAFE_INTEGER; }; _proto.equals = function equals(other) { if (other === this) { return true; } if (other instanceof ValueRange) { return this._minSmallest === other._minSmallest && this._minLargest === other._minLargest && this._maxSmallest === other._maxSmallest && this._maxLargest === other._maxLargest; } return false; }; _proto.hashCode = function hashCode() { return MathUtil.hashCode(this._minSmallest, this._minLargest, this._maxSmallest, this._maxLargest); }; _proto.toString = function toString() { var str = this.minimum() + (this.minimum() !== this.largestMinimum() ? "/" + this.largestMinimum() : ''); str += ' - '; str += this.smallestMaximum() + (this.smallestMaximum() !== this.maximum() ? "/" + this.maximum() : ''); return str; }; ValueRange.of = function of() { if (arguments.length === 2) { return new ValueRange(arguments[0], arguments[0], arguments[1], arguments[1]); } else if (arguments.length === 3) { return new ValueRange(arguments[0], arguments[0], arguments[1], arguments[2]); } else if (arguments.length === 4) { return new ValueRange(arguments[0], arguments[1], arguments[2], arguments[3]); } else { return assert(false, "Invalid number of arguments " + arguments.length, IllegalArgumentException); } }; return ValueRange; }(); var ChronoField = function (_TemporalField) { function ChronoField(name, baseUnit, rangeUnit, range) { var _this; _this = _TemporalField.call(this) || this; _this._name = name; _this._baseUnit = baseUnit; _this._rangeUnit = rangeUnit; _this._range = range; return _this; } _inheritsLoose(ChronoField, _TemporalField); ChronoField.byName = function byName(fieldName) { for (var prop in ChronoField) { if (ChronoField[prop]) { if (ChronoField[prop] instanceof ChronoField && ChronoField[prop].name() === fieldName) { return ChronoField[prop]; } } } }; var _proto = ChronoField.prototype; _proto.name = function name() { return this._name; }; _proto.baseUnit = function baseUnit() { return this._baseUnit; }; _proto.rangeUnit = function rangeUnit() { return this._rangeUnit; }; _proto.range = function range() { return this._range; }; _proto.displayName = function displayName() { return this.toString(); }; _proto.checkValidValue = function checkValidValue(value) { return this.range().checkValidValue(value, this); }; _proto.checkValidIntValue = function checkValidIntValue(value) { return this.range().checkValidIntValue(value, this); }; _proto.isDateBased = function isDateBased() { var dateBased = this === ChronoField.DAY_OF_WEEK || this === ChronoField.ALIGNED_DAY_OF_WEEK_IN_MONTH || this === ChronoField.ALIGNED_DAY_OF_WEEK_IN_YEAR || this === ChronoField.DAY_OF_MONTH || this === ChronoField.DAY_OF_YEAR || this === ChronoField.EPOCH_DAY || this === ChronoField.ALIGNED_WEEK_OF_MONTH || this === ChronoField.ALIGNED_WEEK_OF_YEAR || this === ChronoField.MONTH_OF_YEAR || this === ChronoField.PROLEPTIC_MONTH || this === ChronoField.YEAR_OF_ERA || this === ChronoField.YEAR || this === ChronoField.ERA; return dateBased; }; _proto.isTimeBased = function isTimeBased() { var timeBased = this === ChronoField.NANO_OF_SECOND || this === ChronoField.NANO_OF_DAY || this === ChronoField.MICRO_OF_SECOND || this === ChronoField.MICRO_OF_DAY || this === ChronoField.MILLI_OF_SECOND || this === ChronoField.MILLI_OF_DAY || this === ChronoField.SECOND_OF_MINUTE || this === ChronoField.SECOND_OF_DAY || this === ChronoField.MINUTE_OF_HOUR || this === ChronoField.MINUTE_OF_DAY || this === ChronoField.HOUR_OF_AMPM || this === ChronoField.CLOCK_HOUR_OF_AMPM || this === ChronoField.HOUR_OF_DAY || this === ChronoField.CLOCK_HOUR_OF_DAY || this === ChronoField.AMPM_OF_DAY; return timeBased; }; _proto.rangeRefinedBy = function rangeRefinedBy(temporal) { return temporal.range(this); }; _proto.getFrom = function getFrom(temporal) { return temporal.getLong(this); }; _proto.toString = function toString() { return this.name(); }; _proto.equals = function equals(other) { return this === other; }; _proto.adjustInto = function adjustInto(temporal, newValue) { return temporal.with(this, newValue); }; _proto.isSupportedBy = function isSupportedBy(temporal) { return temporal.isSupported(this); }; return ChronoField; }(TemporalField); function _init$k() { ChronoField.NANO_OF_SECOND = new ChronoField('NanoOfSecond', ChronoUnit.NANOS, ChronoUnit.SECONDS, ValueRange.of(0, 999999999)); ChronoField.NANO_OF_DAY = new ChronoField('NanoOfDay', ChronoUnit.NANOS, ChronoUnit.DAYS, ValueRange.of(0, 86400 * 1000000000 - 1)); ChronoField.MICRO_OF_SECOND = new ChronoField('MicroOfSecond', ChronoUnit.MICROS, ChronoUnit.SECONDS, ValueRange.of(0, 999999)); ChronoField.MICRO_OF_DAY = new ChronoField('MicroOfDay', ChronoUnit.MICROS, ChronoUnit.DAYS, ValueRange.of(0, 86400 * 1000000 - 1)); ChronoField.MILLI_OF_SECOND = new ChronoField('MilliOfSecond', ChronoUnit.MILLIS, ChronoUnit.SECONDS, ValueRange.of(0, 999)); ChronoField.MILLI_OF_DAY = new ChronoField('MilliOfDay', ChronoUnit.MILLIS, ChronoUnit.DAYS, ValueRange.of(0, 86400 * 1000 - 1)); ChronoField.SECOND_OF_MINUTE = new ChronoField('SecondOfMinute', ChronoUnit.SECONDS, ChronoUnit.MINUTES, ValueRange.of(0, 59)); ChronoField.SECOND_OF_DAY = new ChronoField('SecondOfDay', ChronoUnit.SECONDS, ChronoUnit.DAYS, ValueRange.of(0, 86400 - 1)); ChronoField.MINUTE_OF_HOUR = new ChronoField('MinuteOfHour', ChronoUnit.MINUTES, ChronoUnit.HOURS, ValueRange.of(0, 59)); ChronoField.MINUTE_OF_DAY = new ChronoField('MinuteOfDay', ChronoUnit.MINUTES, ChronoUnit.DAYS, ValueRange.of(0, 24 * 60 - 1)); ChronoField.HOUR_OF_AMPM = new ChronoField('HourOfAmPm', ChronoUnit.HOURS, ChronoUnit.HALF_DAYS, ValueRange.of(0, 11)); ChronoField.CLOCK_HOUR_OF_AMPM = new ChronoField('ClockHourOfAmPm', ChronoUnit.HOURS, ChronoUnit.HALF_DAYS, ValueRange.of(1, 12)); ChronoField.HOUR_OF_DAY = new ChronoField('HourOfDay', ChronoUnit.HOURS, ChronoUnit.DAYS, ValueRange.of(0, 23)); ChronoField.CLOCK_HOUR_OF_DAY = new ChronoField('ClockHourOfDay', ChronoUnit.HOURS, ChronoUnit.DAYS, ValueRange.of(1, 24)); ChronoField.AMPM_OF_DAY = new ChronoField('AmPmOfDay', ChronoUnit.HALF_DAYS, ChronoUnit.DAYS, ValueRange.of(0, 1)); ChronoField.DAY_OF_WEEK = new ChronoField('DayOfWeek', ChronoUnit.DAYS, ChronoUnit.WEEKS, ValueRange.of(1, 7)); ChronoField.ALIGNED_DAY_OF_WEEK_IN_MONTH = new ChronoField('AlignedDayOfWeekInMonth', ChronoUnit.DAYS, ChronoUnit.WEEKS, ValueRange.of(1, 7)); ChronoField.ALIGNED_DAY_OF_WEEK_IN_YEAR = new ChronoField('AlignedDayOfWeekInYear', ChronoUnit.DAYS, ChronoUnit.WEEKS, ValueRange.of(1, 7)); ChronoField.DAY_OF_MONTH = new ChronoField('DayOfMonth', ChronoUnit.DAYS, ChronoUnit.MONTHS, ValueRange.of(1, 28, 31), 'day'); ChronoField.DAY_OF_YEAR = new ChronoField('DayOfYear', ChronoUnit.DAYS, ChronoUnit.YEARS, ValueRange.of(1, 365, 366)); ChronoField.EPOCH_DAY = new ChronoField('EpochDay', ChronoUnit.DAYS, ChronoUnit.FOREVER, ValueRange.of(-365961662, 364522971)); ChronoField.ALIGNED_WEEK_OF_MONTH = new ChronoField('AlignedWeekOfMonth', ChronoUnit.WEEKS, ChronoUnit.MONTHS, ValueRange.of(1, 4, 5)); ChronoField.ALIGNED_WEEK_OF_YEAR = new ChronoField('AlignedWeekOfYear', ChronoUnit.WEEKS, ChronoUnit.YEARS, ValueRange.of(1, 53)); ChronoField.MONTH_OF_YEAR = new ChronoField('MonthOfYear', ChronoUnit.MONTHS, ChronoUnit.YEARS, ValueRange.of(1, 12), 'month'); ChronoField.PROLEPTIC_MONTH = new ChronoField('ProlepticMonth', ChronoUnit.MONTHS, ChronoUnit.FOREVER, ValueRange.of(YearConstants.MIN_VALUE * 12, YearConstants.MAX_VALUE * 12 + 11)); ChronoField.YEAR_OF_ERA = new ChronoField('YearOfEra', ChronoUnit.YEARS, ChronoUnit.FOREVER, ValueRange.of(1, YearConstants.MAX_VALUE, YearConstants.MAX_VALUE + 1)); ChronoField.YEAR = new ChronoField('Year', ChronoUnit.YEARS, ChronoUnit.FOREVER, ValueRange.of(YearConstants.MIN_VALUE, YearConstants.MAX_VALUE), 'year'); ChronoField.ERA = new ChronoField('Era', ChronoUnit.ERAS, ChronoUnit.FOREVER, ValueRange.of(0, 1)); ChronoField.INSTANT_SECONDS = new ChronoField('InstantSeconds', ChronoUnit.SECONDS, ChronoUnit.FOREVER, ValueRange.of(MIN_SAFE_INTEGER, MAX_SAFE_INTEGER)); ChronoField.OFFSET_SECONDS = new ChronoField('OffsetSeconds', ChronoUnit.SECONDS, ChronoUnit.FOREVER, ValueRange.of(-18 * 3600, 18 * 3600)); } /** * @copyright (c) 2016, Philipp Thürwächter & Pattrick Hüper * @copyright (c) 2007-present, Stephen Colebourne & Michael Nascimento Santos * @license BSD-3-Clause (see LICENSE in the root directory of this source tree) */var TemporalQueries = function () { function TemporalQueries() {} TemporalQueries.zoneId = function zoneId() { return TemporalQueries.ZONE_ID; }; TemporalQueries.chronology = function chronology() { return TemporalQueries.CHRONO; }; TemporalQueries.precision = function precision() { return TemporalQueries.PRECISION; }; TemporalQueries.zone = function zone() { return TemporalQueries.ZONE; }; TemporalQueries.offset = function offset() { return TemporalQueries.OFFSET; }; TemporalQueries.localDate = function localDate() { return TemporalQueries.LOCAL_DATE; }; TemporalQueries.localTime = function localTime() { return TemporalQueries.LOCAL_TIME; }; return TemporalQueries; }(); /** * @copyright (c) 2016, Philipp Thürwächter & Pattrick Hüper * @copyright (c) 2007-present, Stephen Colebourne & Michael Nascimento Santos * @license BSD-3-Clause (see LICENSE in the root directory of this source tree) */ var TemporalAccessor = function () { function TemporalAccessor() {} var _proto = TemporalAccessor.prototype; _proto.query = function query(_query) { if (_query === TemporalQueries.zoneId() || _query === TemporalQueries.chronology() || _query === TemporalQueries.precision()) { return null; } return _query.queryFrom(this); }; _proto.get = function get(field) { return this.range(field).checkValidIntValue(this.getLong(field), field); }; _proto.getLong = function getLong(field) { abstractMethodFail('getLong'); }; _proto.range = function range(field) { if (field instanceof ChronoField) { if (this.isSupported(field)) { return field.range(); } throw new UnsupportedTemporalTypeException("Unsupported field: " + field); } return field.rangeRefinedBy(this); }; _proto.isSupported = function isSupported(field) { abstractMethodFail('isSupported'); }; return TemporalAccessor; }(); var TemporalQuery = function (_Enum) { function TemporalQuery() { return _Enum.apply(this, arguments) || this; } _inheritsLoose(TemporalQuery, _Enum); var _proto = TemporalQuery.prototype; _proto.queryFrom = function queryFrom(temporal) { abstractMethodFail('queryFrom'); }; return TemporalQuery; }(Enum); function createTemporalQuery(name, queryFromFunction) { var ExtendedTemporalQuery = function (_TemporalQuery) { function ExtendedTemporalQuery() { return _TemporalQuery.apply(this, arguments) || this; } _inheritsLoose(ExtendedTemporalQuery, _TemporalQuery); return ExtendedTemporalQuery; }(TemporalQuery); ExtendedTemporalQuery.prototype.queryFrom = queryFromFunction; return new ExtendedTemporalQuery(name); } var DayOfWeek = function (_TemporalAccessor) { function DayOfWeek(ordinal, name) { var _this; _this = _TemporalAccessor.call(this) || this; _this._ordinal = ordinal; _this._name = name; return _this; } _inheritsLoose(DayOfWeek, _TemporalAccessor); var _proto = DayOfWeek.prototype; _proto.ordinal = function ordinal() { return this._ordinal; }; _proto.name = function name() { return this._name; }; DayOfWeek.values = function values() { return ENUMS.slice(); }; DayOfWeek.valueOf = function valueOf(name) { var ordinal = 0; for (ordinal; ordinal < ENUMS.length; ordinal++) { if (ENUMS[ordinal].name() === name) { break; } } return DayOfWeek.of(ordinal + 1); }; DayOfWeek.of = function of(dayOfWeek) { if (dayOfWeek < 1 || dayOfWeek > 7) { throw new DateTimeException("Invalid value for DayOfWeek: " + dayOfWeek); } return ENUMS[dayOfWeek - 1]; }; DayOfWeek.from = function from(temporal) { assert(temporal != null, 'temporal', NullPointerException); if (temporal instanceof DayOfWeek) { return temporal; } try { return DayOfWeek.of(temporal.get(ChronoField.DAY_OF_WEEK)); } catch (ex) { if (ex instanceof DateTimeException) { throw new DateTimeException("Unable to obtain DayOfWeek from TemporalAccessor: " + temporal + ", type " + (temporal.constructor != null ? temporal.constructor.name : ''), ex); } else { throw ex; } } }; _proto.value = function value() { return this._ordinal + 1; }; _proto.displayName = function displayName(style, locale) { throw new IllegalArgumentException('Pattern using (localized) text not implemented yet!'); }; _proto.isSupported = function isSupported(field) { if (field instanceof ChronoField) { return field === ChronoField.DAY_OF_WEEK; } return field != null && field.isSupportedBy(this); }; _proto.range = function range(field) { if (field === ChronoField.DAY_OF_WEEK) { return field.range(); } else if (field instanceof ChronoField) { throw new UnsupportedTemporalTypeException("Unsupported field: " + field); } return field.rangeRefinedBy(this); }; _proto.get = function get(field) { if (field === ChronoField.DAY_OF_WEEK) { return this.value(); } return this.range(field).checkValidIntValue(this.g