@js-joda/core 6.0.1 → 6.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,4 +1,4 @@
1
- //! @version @js-joda/core - 6.0.1
1
+ //! @version @js-joda/core - 6.2.0
2
2
  //! @copyright (c) 2015-present, Philipp Thürwächter, Pattrick Hüper & js-joda contributors
3
3
  //! @copyright (c) 2007-present, Stephen Colebourne & Michael Nascimento Santos
4
4
  //! @license BSD-3-Clause (see LICENSE in the root directory of this source tree)
@@ -664,10 +664,15 @@ var Duration = function (_TemporalAmount) {
664
664
  if (divisor === 1) {
665
665
  return this;
666
666
  }
667
- var secs = MathUtil.intDiv(this._seconds, divisor);
668
- var secsMod = MathUtil.roundDown((this._seconds / divisor - secs) * LocalTime.NANOS_PER_SECOND);
669
- var nos = MathUtil.intDiv(this._nanos, divisor);
670
- nos = secsMod + nos;
667
+ var seconds = this._seconds;
668
+ var nanos = this._nanos;
669
+ if (seconds < 0 && nanos > 0) {
670
+ seconds += 1;
671
+ nanos -= LocalTime.NANOS_PER_SECOND;
672
+ }
673
+ var secs = MathUtil.intDiv(seconds, divisor);
674
+ var remainder = MathUtil.intMod(seconds, divisor);
675
+ var nos = MathUtil.intDiv(remainder * LocalTime.NANOS_PER_SECOND + nanos, divisor);
671
676
  return Duration.ofSeconds(secs, nos);
672
677
  };
673
678
  _proto.negated = function negated() {
@@ -749,9 +754,12 @@ var Duration = function (_TemporalAmount) {
749
754
  if (this === Duration.ZERO) {
750
755
  return 'PT0S';
751
756
  }
752
- var hours = MathUtil.intDiv(this._seconds, LocalTime.SECONDS_PER_HOUR);
753
- var minutes = MathUtil.intDiv(MathUtil.intMod(this._seconds, LocalTime.SECONDS_PER_HOUR), LocalTime.SECONDS_PER_MINUTE);
754
- var secs = MathUtil.intMod(this._seconds, LocalTime.SECONDS_PER_MINUTE);
757
+ var negativeFraction = this._seconds < 0 && this._nanos > 0;
758
+ var wholeSeconds = negativeFraction ? this._seconds + 1 : this._seconds;
759
+ var fractionNanos = negativeFraction ? LocalTime.NANOS_PER_SECOND - this._nanos : this._nanos;
760
+ var hours = MathUtil.intDiv(wholeSeconds, LocalTime.SECONDS_PER_HOUR);
761
+ var minutes = MathUtil.intDiv(MathUtil.intMod(wholeSeconds, LocalTime.SECONDS_PER_HOUR), LocalTime.SECONDS_PER_MINUTE);
762
+ var secs = MathUtil.intMod(wholeSeconds, LocalTime.SECONDS_PER_MINUTE);
755
763
  var rval = 'PT';
756
764
  if (hours !== 0) {
757
765
  rval += hours + "H";
@@ -759,31 +767,23 @@ var Duration = function (_TemporalAmount) {
759
767
  if (minutes !== 0) {
760
768
  rval += minutes + "M";
761
769
  }
762
- if (secs === 0 && this._nanos === 0 && rval.length > 2) {
770
+ if (secs === 0 && fractionNanos === 0 && rval.length > 2) {
763
771
  return rval;
764
772
  }
765
- if (secs < 0 && this._nanos > 0) {
766
- if (secs === -1) {
767
- rval += '-0';
768
- } else {
769
- rval += secs + 1;
770
- }
773
+ if (secs === 0 && negativeFraction) {
774
+ rval += '-0';
771
775
  } else {
772
- rval += secs;
776
+ rval += "" + secs;
773
777
  }
774
- if (this._nanos > 0) {
775
- rval += '.';
776
- var nanoString;
777
- if (secs < 0) {
778
- nanoString = "" + (2 * LocalTime.NANOS_PER_SECOND - this._nanos);
779
- } else {
780
- nanoString = "" + (LocalTime.NANOS_PER_SECOND + this._nanos);
778
+ if (fractionNanos > 0) {
779
+ var fraction = "" + fractionNanos;
780
+ while (fraction.length < 9) {
781
+ fraction = "0" + fraction;
781
782
  }
782
- nanoString = nanoString.slice(1, nanoString.length);
783
- rval += nanoString;
784
- while (rval.charAt(rval.length - 1) === '0') {
785
- rval = rval.slice(0, rval.length - 1);
783
+ while (fraction.charAt(fraction.length - 1) === '0') {
784
+ fraction = fraction.slice(0, fraction.length - 1);
786
785
  }
786
+ rval += "." + fraction;
787
787
  }
788
788
  rval += 'S';
789
789
  return rval;
@@ -2069,1410 +2069,1426 @@ var ChronoLocalDate = function (_Temporal) {
2069
2069
  return ChronoLocalDate;
2070
2070
  }(Temporal);
2071
2071
 
2072
- /*
2073
- * @copyright (c) 2016, Philipp Thürwächter & Pattrick Hüper
2074
- * @license BSD-3-Clause (see LICENSE in the root directory of this source tree)
2075
- */
2076
-
2077
- var StringUtil = function () {
2078
- function StringUtil() {}
2079
- StringUtil.startsWith = function startsWith(text, pattern) {
2080
- return text.indexOf(pattern) === 0;
2072
+ var IsoFields = {};
2073
+ var QUARTER_DAYS = [0, 90, 181, 273, 0, 91, 182, 274];
2074
+ var Field = function (_TemporalField) {
2075
+ function Field() {
2076
+ return _TemporalField.apply(this, arguments) || this;
2077
+ }
2078
+ _inheritsLoose(Field, _TemporalField);
2079
+ var _proto = Field.prototype;
2080
+ _proto.isDateBased = function isDateBased() {
2081
+ return true;
2081
2082
  };
2082
- StringUtil.hashCode = function hashCode(text) {
2083
- var len = text.length;
2084
- if (len === 0) {
2085
- return 0;
2083
+ _proto.isTimeBased = function isTimeBased() {
2084
+ return false;
2085
+ };
2086
+ _proto._isIso = function _isIso() {
2087
+ return true;
2088
+ };
2089
+ Field._getWeekRangeByLocalDate = function _getWeekRangeByLocalDate(date) {
2090
+ var wby = Field._getWeekBasedYear(date);
2091
+ return ValueRange.of(1, Field._getWeekRangeByYear(wby));
2092
+ };
2093
+ Field._getWeekRangeByYear = function _getWeekRangeByYear(wby) {
2094
+ var date = LocalDate.of(wby, 1, 1);
2095
+ if (date.dayOfWeek() === DayOfWeek.THURSDAY || date.dayOfWeek() === DayOfWeek.WEDNESDAY && date.isLeapYear()) {
2096
+ return 53;
2086
2097
  }
2087
- var hash = 0;
2088
- for (var i = 0; i < len; i++) {
2089
- var chr = text.charCodeAt(i);
2090
- hash = (hash << 5) - hash + chr;
2091
- hash |= 0;
2098
+ return 52;
2099
+ };
2100
+ Field._getWeek = function _getWeek(date) {
2101
+ var dow0 = date.dayOfWeek().ordinal();
2102
+ var doy0 = date.dayOfYear() - 1;
2103
+ var doyThu0 = doy0 + (3 - dow0);
2104
+ var alignedWeek = MathUtil.intDiv(doyThu0, 7);
2105
+ var firstThuDoy0 = doyThu0 - alignedWeek * 7;
2106
+ var firstMonDoy0 = firstThuDoy0 - 3;
2107
+ if (firstMonDoy0 < -3) {
2108
+ firstMonDoy0 += 7;
2092
2109
  }
2093
- return MathUtil.smi(hash);
2110
+ if (doy0 < firstMonDoy0) {
2111
+ return Field._getWeekRangeByLocalDate(date.withDayOfYear(180).minusYears(1)).maximum();
2112
+ }
2113
+ var week = MathUtil.intDiv(doy0 - firstMonDoy0, 7) + 1;
2114
+ if (week === 53) {
2115
+ if ((firstMonDoy0 === -3 || firstMonDoy0 === -2 && date.isLeapYear()) === false) {
2116
+ week = 1;
2117
+ }
2118
+ }
2119
+ return week;
2094
2120
  };
2095
- return StringUtil;
2096
- }();
2097
-
2098
- /*
2099
- * @copyright (c) 2016, Philipp Thürwächter & Pattrick Hüper
2100
- * @copyright (c) 2007-present, Stephen Colebourne & Michael Nascimento Santos
2101
- * @license BSD-3-Clause (see LICENSE in the root directory of this source tree)
2102
- */
2103
-
2104
- var ZoneId = function () {
2105
- function ZoneId() {}
2106
- ZoneId.systemDefault = function systemDefault() {
2107
- throw new DateTimeException('not supported operation');
2121
+ Field._getWeekBasedYear = function _getWeekBasedYear(date) {
2122
+ var year = date.year();
2123
+ var doy = date.dayOfYear();
2124
+ if (doy <= 3) {
2125
+ var dow = date.dayOfWeek().ordinal();
2126
+ if (doy - dow < -2) {
2127
+ year--;
2128
+ }
2129
+ } else if (doy >= 363) {
2130
+ var _dow = date.dayOfWeek().ordinal();
2131
+ doy = doy - 363 - (date.isLeapYear() ? 1 : 0);
2132
+ if (doy - _dow >= 0) {
2133
+ year++;
2134
+ }
2135
+ }
2136
+ return year;
2108
2137
  };
2109
- ZoneId.getAvailableZoneIds = function getAvailableZoneIds() {
2110
- throw new DateTimeException('not supported operation');
2138
+ _proto.displayName = function displayName() {
2139
+ return this.toString();
2111
2140
  };
2112
- ZoneId.of = function of(zoneId) {
2113
- throw new DateTimeException("not supported operation" + zoneId);
2141
+ _proto.resolve = function resolve() {
2142
+ return null;
2114
2143
  };
2115
- ZoneId.ofOffset = function ofOffset(prefix, offset) {
2116
- throw new DateTimeException("not supported operation" + prefix + offset);
2144
+ _proto.name = function name() {
2145
+ return this.toString();
2117
2146
  };
2118
- ZoneId.from = function from(temporal) {
2119
- throw new DateTimeException("not supported operation" + temporal);
2147
+ return Field;
2148
+ }(TemporalField);
2149
+ var DAY_OF_QUARTER_FIELD = function (_Field) {
2150
+ function DAY_OF_QUARTER_FIELD() {
2151
+ return _Field.apply(this, arguments) || this;
2152
+ }
2153
+ _inheritsLoose(DAY_OF_QUARTER_FIELD, _Field);
2154
+ var _proto2 = DAY_OF_QUARTER_FIELD.prototype;
2155
+ _proto2.toString = function toString() {
2156
+ return 'DayOfQuarter';
2120
2157
  };
2121
- var _proto = ZoneId.prototype;
2122
- _proto.id = function id() {
2123
- abstractMethodFail('ZoneId.id');
2158
+ _proto2.baseUnit = function baseUnit() {
2159
+ return ChronoUnit.DAYS;
2124
2160
  };
2125
- _proto.rules = function rules() {
2126
- abstractMethodFail('ZoneId.rules');
2161
+ _proto2.rangeUnit = function rangeUnit() {
2162
+ return QUARTER_YEARS;
2127
2163
  };
2128
- _proto.normalized = function normalized() {
2129
- var rules = this.rules();
2130
- if (rules.isFixedOffset()) {
2131
- return rules.offset(Instant.EPOCH);
2132
- }
2133
- return this;
2164
+ _proto2.range = function range() {
2165
+ return ValueRange.of(1, 90, 92);
2134
2166
  };
2135
- _proto.equals = function equals(other) {
2136
- if (this === other) {
2137
- return true;
2167
+ _proto2.isSupportedBy = function isSupportedBy(temporal) {
2168
+ return temporal.isSupported(ChronoField.DAY_OF_YEAR) && temporal.isSupported(ChronoField.MONTH_OF_YEAR) && temporal.isSupported(ChronoField.YEAR) && this._isIso(temporal);
2169
+ };
2170
+ _proto2.rangeRefinedBy = function rangeRefinedBy(temporal) {
2171
+ if (temporal.isSupported(this) === false) {
2172
+ throw new UnsupportedTemporalTypeException('Unsupported field: DayOfQuarter');
2138
2173
  }
2139
- if (other instanceof ZoneId) {
2140
- return this.id() === other.id();
2174
+ var qoy = temporal.getLong(QUARTER_OF_YEAR);
2175
+ if (qoy === 1) {
2176
+ var year = temporal.getLong(ChronoField.YEAR);
2177
+ return IsoChronology.isLeapYear(year) ? ValueRange.of(1, 91) : ValueRange.of(1, 90);
2178
+ } else if (qoy === 2) {
2179
+ return ValueRange.of(1, 91);
2180
+ } else if (qoy === 3 || qoy === 4) {
2181
+ return ValueRange.of(1, 92);
2141
2182
  }
2142
- return false;
2143
- };
2144
- _proto.hashCode = function hashCode() {
2145
- return StringUtil.hashCode(this.id());
2146
- };
2147
- _proto.toString = function toString() {
2148
- return this.id();
2149
- };
2150
- _proto.toJSON = function toJSON() {
2151
- return this.toString();
2183
+ return this.range();
2152
2184
  };
2153
- return ZoneId;
2154
- }();
2155
-
2156
- var ZoneRules = function () {
2157
- function ZoneRules() {}
2158
- ZoneRules.of = function of(offset) {
2159
- requireNonNull(offset, 'offset');
2160
- return new Fixed(offset);
2185
+ _proto2.getFrom = function getFrom(temporal) {
2186
+ if (temporal.isSupported(this) === false) {
2187
+ throw new UnsupportedTemporalTypeException('Unsupported field: DayOfQuarter');
2188
+ }
2189
+ var doy = temporal.get(ChronoField.DAY_OF_YEAR);
2190
+ var moy = temporal.get(ChronoField.MONTH_OF_YEAR);
2191
+ var year = temporal.getLong(ChronoField.YEAR);
2192
+ return doy - QUARTER_DAYS[MathUtil.intDiv(moy - 1, 3) + (IsoChronology.isLeapYear(year) ? 4 : 0)];
2161
2193
  };
2162
- var _proto = ZoneRules.prototype;
2163
- _proto.isFixedOffset = function isFixedOffset() {
2164
- abstractMethodFail('ZoneRules.isFixedOffset');
2194
+ _proto2.adjustInto = function adjustInto(temporal, newValue) {
2195
+ var curValue = this.getFrom(temporal);
2196
+ this.range().checkValidValue(newValue, this);
2197
+ return temporal.with(ChronoField.DAY_OF_YEAR, temporal.getLong(ChronoField.DAY_OF_YEAR) + (newValue - curValue));
2165
2198
  };
2166
- _proto.offset = function offset(instantOrLocalDateTime) {
2167
- if (instantOrLocalDateTime instanceof Instant) {
2168
- return this.offsetOfInstant(instantOrLocalDateTime);
2199
+ _proto2.resolve = function resolve(fieldValues, partialTemporal, resolverStyle) {
2200
+ var yearLong = fieldValues.get(ChronoField.YEAR);
2201
+ var qoyLong = fieldValues.get(QUARTER_OF_YEAR);
2202
+ if (yearLong == null || qoyLong == null) {
2203
+ return null;
2204
+ }
2205
+ var y = ChronoField.YEAR.checkValidIntValue(yearLong);
2206
+ var doq = fieldValues.get(DAY_OF_QUARTER);
2207
+ var date;
2208
+ if (resolverStyle === ResolverStyle.LENIENT) {
2209
+ var qoy = qoyLong;
2210
+ date = LocalDate.of(y, 1, 1);
2211
+ date = date.plusMonths(MathUtil.safeMultiply(MathUtil.safeSubtract(qoy, 1), 3));
2212
+ date = date.plusDays(MathUtil.safeSubtract(doq, 1));
2169
2213
  } else {
2170
- return this.offsetOfLocalDateTime(instantOrLocalDateTime);
2214
+ var _qoy = QUARTER_OF_YEAR.range().checkValidIntValue(qoyLong, QUARTER_OF_YEAR);
2215
+ if (resolverStyle === ResolverStyle.STRICT) {
2216
+ var max = 92;
2217
+ if (_qoy === 1) {
2218
+ max = IsoChronology.isLeapYear(y) ? 91 : 90;
2219
+ } else if (_qoy === 2) {
2220
+ max = 91;
2221
+ }
2222
+ ValueRange.of(1, max).checkValidValue(doq, this);
2223
+ } else {
2224
+ this.range().checkValidValue(doq, this);
2225
+ }
2226
+ date = LocalDate.of(y, (_qoy - 1) * 3 + 1, 1).plusDays(doq - 1);
2171
2227
  }
2228
+ fieldValues.remove(this);
2229
+ fieldValues.remove(ChronoField.YEAR);
2230
+ fieldValues.remove(QUARTER_OF_YEAR);
2231
+ return date;
2172
2232
  };
2173
- _proto.offsetOfInstant = function offsetOfInstant(instant) {
2174
- abstractMethodFail('ZoneRules.offsetInstant');
2233
+ return DAY_OF_QUARTER_FIELD;
2234
+ }(Field);
2235
+ var QUARTER_OF_YEAR_FIELD = function (_Field2) {
2236
+ function QUARTER_OF_YEAR_FIELD() {
2237
+ return _Field2.apply(this, arguments) || this;
2238
+ }
2239
+ _inheritsLoose(QUARTER_OF_YEAR_FIELD, _Field2);
2240
+ var _proto3 = QUARTER_OF_YEAR_FIELD.prototype;
2241
+ _proto3.toString = function toString() {
2242
+ return 'QuarterOfYear';
2175
2243
  };
2176
- _proto.offsetOfEpochMilli = function offsetOfEpochMilli(epochMilli) {
2177
- abstractMethodFail('ZoneRules.offsetOfEpochMilli');
2244
+ _proto3.baseUnit = function baseUnit() {
2245
+ return QUARTER_YEARS;
2178
2246
  };
2179
- _proto.offsetOfLocalDateTime = function offsetOfLocalDateTime(localDateTime) {
2180
- abstractMethodFail('ZoneRules.offsetLocalDateTime');
2247
+ _proto3.rangeUnit = function rangeUnit() {
2248
+ return ChronoUnit.YEARS;
2181
2249
  };
2182
- _proto.validOffsets = function validOffsets(localDateTime) {
2183
- abstractMethodFail('ZoneRules.validOffsets');
2250
+ _proto3.range = function range() {
2251
+ return ValueRange.of(1, 4);
2184
2252
  };
2185
- _proto.transition = function transition(localDateTime) {
2186
- abstractMethodFail('ZoneRules.transition');
2253
+ _proto3.isSupportedBy = function isSupportedBy(temporal) {
2254
+ return temporal.isSupported(ChronoField.MONTH_OF_YEAR) && this._isIso(temporal);
2187
2255
  };
2188
- _proto.standardOffset = function standardOffset(instant) {
2189
- abstractMethodFail('ZoneRules.standardOffset');
2190
- };
2191
- _proto.daylightSavings = function daylightSavings(instant) {
2192
- abstractMethodFail('ZoneRules.daylightSavings');
2193
- };
2194
- _proto.isDaylightSavings = function isDaylightSavings(instant) {
2195
- abstractMethodFail('ZoneRules.isDaylightSavings');
2196
- };
2197
- _proto.isValidOffset = function isValidOffset(localDateTime, offset) {
2198
- abstractMethodFail('ZoneRules.isValidOffset');
2199
- };
2200
- _proto.nextTransition = function nextTransition(instant) {
2201
- abstractMethodFail('ZoneRules.nextTransition');
2256
+ _proto3.rangeRefinedBy = function rangeRefinedBy(temporal) {
2257
+ return this.range();
2202
2258
  };
2203
- _proto.previousTransition = function previousTransition(instant) {
2204
- abstractMethodFail('ZoneRules.previousTransition');
2259
+ _proto3.getFrom = function getFrom(temporal) {
2260
+ if (temporal.isSupported(this) === false) {
2261
+ throw new UnsupportedTemporalTypeException('Unsupported field: QuarterOfYear');
2262
+ }
2263
+ var moy = temporal.getLong(ChronoField.MONTH_OF_YEAR);
2264
+ return MathUtil.intDiv(moy + 2, 3);
2205
2265
  };
2206
- _proto.transitions = function transitions() {
2207
- abstractMethodFail('ZoneRules.transitions');
2266
+ _proto3.adjustInto = function adjustInto(temporal, newValue) {
2267
+ var curValue = this.getFrom(temporal);
2268
+ this.range().checkValidValue(newValue, this);
2269
+ return temporal.with(ChronoField.MONTH_OF_YEAR, temporal.getLong(ChronoField.MONTH_OF_YEAR) + (newValue - curValue) * 3);
2208
2270
  };
2209
- _proto.transitionRules = function transitionRules() {
2210
- abstractMethodFail('ZoneRules.transitionRules');
2271
+ return QUARTER_OF_YEAR_FIELD;
2272
+ }(Field);
2273
+ var WEEK_OF_WEEK_BASED_YEAR_FIELD = function (_Field3) {
2274
+ function WEEK_OF_WEEK_BASED_YEAR_FIELD() {
2275
+ return _Field3.apply(this, arguments) || this;
2276
+ }
2277
+ _inheritsLoose(WEEK_OF_WEEK_BASED_YEAR_FIELD, _Field3);
2278
+ var _proto4 = WEEK_OF_WEEK_BASED_YEAR_FIELD.prototype;
2279
+ _proto4.toString = function toString() {
2280
+ return 'WeekOfWeekBasedYear';
2211
2281
  };
2212
- _proto.toString = function toString() {
2213
- abstractMethodFail('ZoneRules.toString');
2282
+ _proto4.baseUnit = function baseUnit() {
2283
+ return ChronoUnit.WEEKS;
2214
2284
  };
2215
- _proto.toJSON = function toJSON() {
2216
- return this.toString();
2285
+ _proto4.rangeUnit = function rangeUnit() {
2286
+ return WEEK_BASED_YEARS;
2217
2287
  };
2218
- return ZoneRules;
2219
- }();
2220
- var Fixed = function (_ZoneRules) {
2221
- function Fixed(offset) {
2222
- var _this;
2223
- _this = _ZoneRules.call(this) || this;
2224
- _this._offset = offset;
2225
- return _this;
2226
- }
2227
- _inheritsLoose(Fixed, _ZoneRules);
2228
- var _proto2 = Fixed.prototype;
2229
- _proto2.isFixedOffset = function isFixedOffset() {
2230
- return true;
2288
+ _proto4.range = function range() {
2289
+ return ValueRange.of(1, 52, 53);
2231
2290
  };
2232
- _proto2.offsetOfInstant = function offsetOfInstant() {
2233
- return this._offset;
2291
+ _proto4.isSupportedBy = function isSupportedBy(temporal) {
2292
+ return temporal.isSupported(ChronoField.EPOCH_DAY) && this._isIso(temporal);
2234
2293
  };
2235
- _proto2.offsetOfEpochMilli = function offsetOfEpochMilli() {
2236
- return this._offset;
2294
+ _proto4.rangeRefinedBy = function rangeRefinedBy(temporal) {
2295
+ if (temporal.isSupported(this) === false) {
2296
+ throw new UnsupportedTemporalTypeException('Unsupported field: WeekOfWeekBasedYear');
2297
+ }
2298
+ return Field._getWeekRangeByLocalDate(LocalDate.from(temporal));
2237
2299
  };
2238
- _proto2.offsetOfLocalDateTime = function offsetOfLocalDateTime() {
2239
- return this._offset;
2300
+ _proto4.getFrom = function getFrom(temporal) {
2301
+ if (temporal.isSupported(this) === false) {
2302
+ throw new UnsupportedTemporalTypeException('Unsupported field: WeekOfWeekBasedYear');
2303
+ }
2304
+ return Field._getWeek(LocalDate.from(temporal));
2240
2305
  };
2241
- _proto2.validOffsets = function validOffsets() {
2242
- return [this._offset];
2306
+ _proto4.adjustInto = function adjustInto(temporal, newValue) {
2307
+ this.range().checkValidValue(newValue, this);
2308
+ return temporal.plus(MathUtil.safeSubtract(newValue, this.getFrom(temporal)), ChronoUnit.WEEKS);
2243
2309
  };
2244
- _proto2.transition = function transition() {
2245
- return null;
2310
+ _proto4.resolve = function resolve(fieldValues, partialTemporal, resolverStyle) {
2311
+ var wbyLong = fieldValues.get(WEEK_BASED_YEAR);
2312
+ var dowLong = fieldValues.get(ChronoField.DAY_OF_WEEK);
2313
+ if (wbyLong == null || dowLong == null) {
2314
+ return null;
2315
+ }
2316
+ var wby = WEEK_BASED_YEAR.range().checkValidIntValue(wbyLong, WEEK_BASED_YEAR);
2317
+ var wowby = fieldValues.get(WEEK_OF_WEEK_BASED_YEAR);
2318
+ var date;
2319
+ if (resolverStyle === ResolverStyle.LENIENT) {
2320
+ var dow = dowLong;
2321
+ var weeks = 0;
2322
+ if (dow > 7) {
2323
+ weeks = MathUtil.intDiv(dow - 1, 7);
2324
+ dow = MathUtil.intMod(dow - 1, 7) + 1;
2325
+ } else if (dow < 1) {
2326
+ weeks = MathUtil.intDiv(dow, 7) - 1;
2327
+ dow = MathUtil.intMod(dow, 7) + 7;
2328
+ }
2329
+ date = LocalDate.of(wby, 1, 4).plusWeeks(wowby - 1).plusWeeks(weeks).with(ChronoField.DAY_OF_WEEK, dow);
2330
+ } else {
2331
+ var _dow2 = ChronoField.DAY_OF_WEEK.checkValidIntValue(dowLong);
2332
+ if (resolverStyle === ResolverStyle.STRICT) {
2333
+ var temp = LocalDate.of(wby, 1, 4);
2334
+ var range = Field._getWeekRangeByLocalDate(temp);
2335
+ range.checkValidValue(wowby, this);
2336
+ } else {
2337
+ this.range().checkValidValue(wowby, this);
2338
+ }
2339
+ date = LocalDate.of(wby, 1, 4).plusWeeks(wowby - 1).with(ChronoField.DAY_OF_WEEK, _dow2);
2340
+ }
2341
+ fieldValues.remove(this);
2342
+ fieldValues.remove(WEEK_BASED_YEAR);
2343
+ fieldValues.remove(ChronoField.DAY_OF_WEEK);
2344
+ return date;
2246
2345
  };
2247
- _proto2.standardOffset = function standardOffset() {
2248
- return this._offset;
2346
+ _proto4.displayName = function displayName() {
2347
+ return 'Week';
2249
2348
  };
2250
- _proto2.daylightSavings = function daylightSavings() {
2251
- return Duration.ZERO;
2349
+ return WEEK_OF_WEEK_BASED_YEAR_FIELD;
2350
+ }(Field);
2351
+ var WEEK_BASED_YEAR_FIELD = function (_Field4) {
2352
+ function WEEK_BASED_YEAR_FIELD() {
2353
+ return _Field4.apply(this, arguments) || this;
2354
+ }
2355
+ _inheritsLoose(WEEK_BASED_YEAR_FIELD, _Field4);
2356
+ var _proto5 = WEEK_BASED_YEAR_FIELD.prototype;
2357
+ _proto5.toString = function toString() {
2358
+ return 'WeekBasedYear';
2252
2359
  };
2253
- _proto2.isDaylightSavings = function isDaylightSavings() {
2254
- return false;
2360
+ _proto5.baseUnit = function baseUnit() {
2361
+ return WEEK_BASED_YEARS;
2255
2362
  };
2256
- _proto2.isValidOffset = function isValidOffset(localDateTime, offset) {
2257
- return this._offset.equals(offset);
2363
+ _proto5.rangeUnit = function rangeUnit() {
2364
+ return ChronoUnit.FOREVER;
2258
2365
  };
2259
- _proto2.nextTransition = function nextTransition() {
2260
- return null;
2366
+ _proto5.range = function range() {
2367
+ return ChronoField.YEAR.range();
2261
2368
  };
2262
- _proto2.previousTransition = function previousTransition() {
2263
- return null;
2369
+ _proto5.isSupportedBy = function isSupportedBy(temporal) {
2370
+ return temporal.isSupported(ChronoField.EPOCH_DAY) && this._isIso(temporal);
2264
2371
  };
2265
- _proto2.transitions = function transitions() {
2266
- return [];
2372
+ _proto5.rangeRefinedBy = function rangeRefinedBy(temporal) {
2373
+ return ChronoField.YEAR.range();
2267
2374
  };
2268
- _proto2.transitionRules = function transitionRules() {
2269
- return [];
2375
+ _proto5.getFrom = function getFrom(temporal) {
2376
+ if (temporal.isSupported(this) === false) {
2377
+ throw new UnsupportedTemporalTypeException('Unsupported field: WeekBasedYear');
2378
+ }
2379
+ return Field._getWeekBasedYear(LocalDate.from(temporal));
2270
2380
  };
2271
- _proto2.equals = function equals(other) {
2272
- if (this === other) {
2273
- return true;
2381
+ _proto5.adjustInto = function adjustInto(temporal, newValue) {
2382
+ if (this.isSupportedBy(temporal) === false) {
2383
+ throw new UnsupportedTemporalTypeException('Unsupported field: WeekBasedYear');
2274
2384
  }
2275
- if (other instanceof Fixed) {
2276
- return this._offset.equals(other._offset);
2385
+ var newWby = this.range().checkValidIntValue(newValue, WEEK_BASED_YEAR);
2386
+ var date = LocalDate.from(temporal);
2387
+ var dow = date.get(ChronoField.DAY_OF_WEEK);
2388
+ var week = Field._getWeek(date);
2389
+ if (week === 53 && Field._getWeekRangeByYear(newWby) === 52) {
2390
+ week = 52;
2277
2391
  }
2278
- return false;
2279
- };
2280
- _proto2.toString = function toString() {
2281
- return "FixedRules:" + this._offset.toString();
2392
+ var resolved = LocalDate.of(newWby, 1, 4);
2393
+ var days = dow - resolved.get(ChronoField.DAY_OF_WEEK) + (week - 1) * 7;
2394
+ resolved = resolved.plusDays(days);
2395
+ return temporal.with(resolved);
2282
2396
  };
2283
- return Fixed;
2284
- }(ZoneRules);
2285
-
2286
- var SECONDS_CACHE = {};
2287
- var ID_CACHE = {};
2288
- var ZoneOffset = function (_ZoneId) {
2289
- function ZoneOffset(totalSeconds) {
2397
+ return WEEK_BASED_YEAR_FIELD;
2398
+ }(Field);
2399
+ var Unit = function (_TemporalUnit) {
2400
+ function Unit(name, estimatedDuration) {
2290
2401
  var _this;
2291
- _this = _ZoneId.call(this) || this;
2292
- ZoneOffset._validateTotalSeconds(totalSeconds);
2293
- _this._totalSeconds = MathUtil.safeToInt(totalSeconds);
2294
- _this._rules = ZoneRules.of(_this);
2295
- _this._id = ZoneOffset._buildId(totalSeconds);
2402
+ _this = _TemporalUnit.call(this) || this;
2403
+ _this._name = name;
2404
+ _this._duration = estimatedDuration;
2296
2405
  return _this;
2297
2406
  }
2298
- _inheritsLoose(ZoneOffset, _ZoneId);
2299
- var _proto = ZoneOffset.prototype;
2300
- _proto.totalSeconds = function totalSeconds() {
2301
- return this._totalSeconds;
2407
+ _inheritsLoose(Unit, _TemporalUnit);
2408
+ var _proto6 = Unit.prototype;
2409
+ _proto6.duration = function duration() {
2410
+ return this._duration;
2302
2411
  };
2303
- _proto.id = function id() {
2304
- return this._id;
2412
+ _proto6.isDurationEstimated = function isDurationEstimated() {
2413
+ return true;
2305
2414
  };
2306
- ZoneOffset._buildId = function _buildId(totalSeconds) {
2307
- if (totalSeconds === 0) {
2308
- return 'Z';
2309
- } else {
2310
- var absTotalSeconds = Math.abs(totalSeconds);
2311
- var absHours = MathUtil.intDiv(absTotalSeconds, LocalTime.SECONDS_PER_HOUR);
2312
- var absMinutes = MathUtil.intMod(MathUtil.intDiv(absTotalSeconds, LocalTime.SECONDS_PER_MINUTE), LocalTime.MINUTES_PER_HOUR);
2313
- var buf = "" + (totalSeconds < 0 ? '-' : '+') + (absHours < 10 ? '0' : '') + absHours + (absMinutes < 10 ? ':0' : ':') + absMinutes;
2314
- var absSeconds = MathUtil.intMod(absTotalSeconds, LocalTime.SECONDS_PER_MINUTE);
2315
- if (absSeconds !== 0) {
2316
- buf += (absSeconds < 10 ? ':0' : ':') + absSeconds;
2317
- }
2318
- return buf;
2319
- }
2415
+ _proto6.isDateBased = function isDateBased() {
2416
+ return true;
2320
2417
  };
2321
- ZoneOffset._validateTotalSeconds = function _validateTotalSeconds(totalSeconds) {
2322
- if (Math.abs(totalSeconds) > ZoneOffset.MAX_SECONDS) {
2323
- throw new DateTimeException('Zone offset not in valid range: -18:00 to +18:00');
2418
+ _proto6.isTimeBased = function isTimeBased() {
2419
+ return false;
2420
+ };
2421
+ _proto6.isSupportedBy = function isSupportedBy(temporal) {
2422
+ return temporal.isSupported(ChronoField.EPOCH_DAY);
2423
+ };
2424
+ _proto6.addTo = function addTo(temporal, periodToAdd) {
2425
+ switch (this) {
2426
+ case WEEK_BASED_YEARS:
2427
+ {
2428
+ var added = MathUtil.safeAdd(temporal.get(WEEK_BASED_YEAR), periodToAdd);
2429
+ return temporal.with(WEEK_BASED_YEAR, added);
2430
+ }
2431
+ case QUARTER_YEARS:
2432
+ return temporal.plus(MathUtil.intDiv(periodToAdd, 256), ChronoUnit.YEARS).plus(MathUtil.intMod(periodToAdd, 256) * 3, ChronoUnit.MONTHS);
2433
+ default:
2434
+ throw new IllegalStateException('Unreachable');
2324
2435
  }
2325
2436
  };
2326
- ZoneOffset._validate = function _validate(hours, minutes, seconds) {
2327
- if (hours < -18 || hours > 18) {
2328
- throw new DateTimeException("Zone offset hours not in valid range: value " + hours + " is not in the range -18 to 18");
2329
- }
2330
- if (hours > 0) {
2331
- if (minutes < 0 || seconds < 0) {
2332
- throw new DateTimeException('Zone offset minutes and seconds must be positive because hours is positive');
2333
- }
2334
- } else if (hours < 0) {
2335
- if (minutes > 0 || seconds > 0) {
2336
- throw new DateTimeException('Zone offset minutes and seconds must be negative because hours is negative');
2337
- }
2338
- } else if (minutes > 0 && seconds < 0 || minutes < 0 && seconds > 0) {
2339
- throw new DateTimeException('Zone offset minutes and seconds must have the same sign');
2340
- }
2341
- if (Math.abs(minutes) > 59) {
2342
- throw new DateTimeException("Zone offset minutes not in valid range: abs(value) " + Math.abs(minutes) + " is not in the range 0 to 59");
2343
- }
2344
- if (Math.abs(seconds) > 59) {
2345
- throw new DateTimeException("Zone offset seconds not in valid range: abs(value) " + Math.abs(seconds) + " is not in the range 0 to 59");
2346
- }
2347
- if (Math.abs(hours) === 18 && (Math.abs(minutes) > 0 || Math.abs(seconds) > 0)) {
2348
- throw new DateTimeException('Zone offset not in valid range: -18:00 to +18:00');
2349
- }
2350
- };
2351
- ZoneOffset.of = function of(offsetId) {
2352
- requireNonNull(offsetId, 'offsetId');
2353
- var offset = ID_CACHE[offsetId];
2354
- if (offset != null) {
2355
- return offset;
2356
- }
2357
- var hours, minutes, seconds;
2358
- switch (offsetId.length) {
2359
- case 2:
2360
- offsetId = offsetId[0] + "0" + offsetId[1];
2361
- case 3:
2362
- hours = ZoneOffset._parseNumber(offsetId, 1, false);
2363
- minutes = 0;
2364
- seconds = 0;
2365
- break;
2366
- case 5:
2367
- hours = ZoneOffset._parseNumber(offsetId, 1, false);
2368
- minutes = ZoneOffset._parseNumber(offsetId, 3, false);
2369
- seconds = 0;
2370
- break;
2371
- case 6:
2372
- hours = ZoneOffset._parseNumber(offsetId, 1, false);
2373
- minutes = ZoneOffset._parseNumber(offsetId, 4, true);
2374
- seconds = 0;
2375
- break;
2376
- case 7:
2377
- hours = ZoneOffset._parseNumber(offsetId, 1, false);
2378
- minutes = ZoneOffset._parseNumber(offsetId, 3, false);
2379
- seconds = ZoneOffset._parseNumber(offsetId, 5, false);
2380
- break;
2381
- case 9:
2382
- hours = ZoneOffset._parseNumber(offsetId, 1, false);
2383
- minutes = ZoneOffset._parseNumber(offsetId, 4, true);
2384
- seconds = ZoneOffset._parseNumber(offsetId, 7, true);
2385
- break;
2437
+ _proto6.between = function between(temporal1, temporal2) {
2438
+ switch (this) {
2439
+ case WEEK_BASED_YEARS:
2440
+ return MathUtil.safeSubtract(temporal2.getLong(WEEK_BASED_YEAR), temporal1.getLong(WEEK_BASED_YEAR));
2441
+ case QUARTER_YEARS:
2442
+ return MathUtil.intDiv(temporal1.until(temporal2, ChronoUnit.MONTHS), 3);
2386
2443
  default:
2387
- throw new DateTimeException("Invalid ID for ZoneOffset, invalid format: " + offsetId);
2388
- }
2389
- var first = offsetId[0];
2390
- if (first !== '+' && first !== '-') {
2391
- throw new DateTimeException("Invalid ID for ZoneOffset, plus/minus not found when expected: " + offsetId);
2392
- }
2393
- if (first === '-') {
2394
- return ZoneOffset.ofHoursMinutesSeconds(-hours, -minutes, -seconds);
2395
- } else {
2396
- return ZoneOffset.ofHoursMinutesSeconds(hours, minutes, seconds);
2397
- }
2398
- };
2399
- ZoneOffset._parseNumber = function _parseNumber(offsetId, pos, precededByColon) {
2400
- if (precededByColon && offsetId[pos - 1] !== ':') {
2401
- throw new DateTimeException("Invalid ID for ZoneOffset, colon not found when expected: " + offsetId);
2402
- }
2403
- var ch1 = offsetId[pos];
2404
- var ch2 = offsetId[pos + 1];
2405
- if (ch1 < '0' || ch1 > '9' || ch2 < '0' || ch2 > '9') {
2406
- throw new DateTimeException("Invalid ID for ZoneOffset, non numeric characters found: " + offsetId);
2444
+ throw new IllegalStateException('Unreachable');
2407
2445
  }
2408
- return (ch1.charCodeAt(0) - 48) * 10 + (ch2.charCodeAt(0) - 48);
2409
2446
  };
2410
- ZoneOffset.ofHours = function ofHours(hours) {
2411
- return ZoneOffset.ofHoursMinutesSeconds(hours, 0, 0);
2447
+ _proto6.toString = function toString() {
2448
+ return this._name;
2412
2449
  };
2413
- ZoneOffset.ofHoursMinutes = function ofHoursMinutes(hours, minutes) {
2414
- return ZoneOffset.ofHoursMinutesSeconds(hours, minutes, 0);
2450
+ return Unit;
2451
+ }(TemporalUnit);
2452
+ var DAY_OF_QUARTER = null;
2453
+ var QUARTER_OF_YEAR = null;
2454
+ var WEEK_OF_WEEK_BASED_YEAR = null;
2455
+ var WEEK_BASED_YEAR = null;
2456
+ var WEEK_BASED_YEARS = null;
2457
+ var QUARTER_YEARS = null;
2458
+ function _init$g() {
2459
+ DAY_OF_QUARTER = new DAY_OF_QUARTER_FIELD();
2460
+ QUARTER_OF_YEAR = new QUARTER_OF_YEAR_FIELD();
2461
+ WEEK_OF_WEEK_BASED_YEAR = new WEEK_OF_WEEK_BASED_YEAR_FIELD();
2462
+ WEEK_BASED_YEAR = new WEEK_BASED_YEAR_FIELD();
2463
+ WEEK_BASED_YEARS = new Unit('WeekBasedYears', Duration.ofSeconds(31556952));
2464
+ QUARTER_YEARS = new Unit('QuarterYears', Duration.ofSeconds(31556952 / 4));
2465
+ IsoFields.DAY_OF_QUARTER = DAY_OF_QUARTER;
2466
+ IsoFields.QUARTER_OF_YEAR = QUARTER_OF_YEAR;
2467
+ IsoFields.WEEK_OF_WEEK_BASED_YEAR = WEEK_OF_WEEK_BASED_YEAR;
2468
+ IsoFields.WEEK_BASED_YEAR = WEEK_BASED_YEAR;
2469
+ IsoFields.WEEK_BASED_YEARS = WEEK_BASED_YEARS;
2470
+ IsoFields.QUARTER_YEARS = QUARTER_YEARS;
2471
+ LocalDate.prototype.isoWeekOfWeekyear = function () {
2472
+ return this.get(IsoFields.WEEK_OF_WEEK_BASED_YEAR);
2415
2473
  };
2416
- ZoneOffset.ofHoursMinutesSeconds = function ofHoursMinutesSeconds(hours, minutes, seconds) {
2417
- ZoneOffset._validate(hours, minutes, seconds);
2418
- var totalSeconds = hours * LocalTime.SECONDS_PER_HOUR + minutes * LocalTime.SECONDS_PER_MINUTE + seconds;
2419
- return ZoneOffset.ofTotalSeconds(totalSeconds);
2474
+ LocalDate.prototype.isoWeekyear = function () {
2475
+ return this.get(IsoFields.WEEK_BASED_YEAR);
2420
2476
  };
2421
- ZoneOffset.ofTotalMinutes = function ofTotalMinutes(totalMinutes) {
2422
- var totalSeconds = totalMinutes * LocalTime.SECONDS_PER_MINUTE;
2423
- return ZoneOffset.ofTotalSeconds(totalSeconds);
2477
+ }
2478
+
2479
+ /*
2480
+ * @copyright (c) 2016, Philipp Thürwächter & Pattrick Hüper
2481
+ * @license BSD-3-Clause (see LICENSE in the root directory of this source tree)
2482
+ */
2483
+
2484
+ var StringUtil = function () {
2485
+ function StringUtil() {}
2486
+ StringUtil.startsWith = function startsWith(text, pattern) {
2487
+ return text.indexOf(pattern) === 0;
2424
2488
  };
2425
- ZoneOffset.ofTotalSeconds = function ofTotalSeconds(totalSeconds) {
2426
- if (totalSeconds % (15 * LocalTime.SECONDS_PER_MINUTE) === 0) {
2427
- var totalSecs = totalSeconds;
2428
- var result = SECONDS_CACHE[totalSecs];
2429
- if (result == null) {
2430
- result = new ZoneOffset(totalSeconds);
2431
- SECONDS_CACHE[totalSecs] = result;
2432
- ID_CACHE[result.id()] = result;
2433
- }
2434
- return result;
2435
- } else {
2436
- return new ZoneOffset(totalSeconds);
2489
+ StringUtil.hashCode = function hashCode(text) {
2490
+ var len = text.length;
2491
+ if (len === 0) {
2492
+ return 0;
2437
2493
  }
2494
+ var hash = 0;
2495
+ for (var i = 0; i < len; i++) {
2496
+ var chr = text.charCodeAt(i);
2497
+ hash = (hash << 5) - hash + chr;
2498
+ hash |= 0;
2499
+ }
2500
+ return MathUtil.smi(hash);
2438
2501
  };
2439
- _proto.rules = function rules() {
2440
- return this._rules;
2502
+ return StringUtil;
2503
+ }();
2504
+
2505
+ /*
2506
+ * @copyright (c) 2016, Philipp Thürwächter & Pattrick Hüper
2507
+ * @copyright (c) 2007-present, Stephen Colebourne & Michael Nascimento Santos
2508
+ * @license BSD-3-Clause (see LICENSE in the root directory of this source tree)
2509
+ */
2510
+
2511
+ var ZoneId = function () {
2512
+ function ZoneId() {}
2513
+ ZoneId.systemDefault = function systemDefault() {
2514
+ throw new DateTimeException('not supported operation');
2441
2515
  };
2442
- _proto.get = function get(field) {
2443
- return this.getLong(field);
2516
+ ZoneId.getAvailableZoneIds = function getAvailableZoneIds() {
2517
+ throw new DateTimeException('not supported operation');
2444
2518
  };
2445
- _proto.getLong = function getLong(field) {
2446
- if (field === ChronoField.OFFSET_SECONDS) {
2447
- return this._totalSeconds;
2448
- } else if (field instanceof ChronoField) {
2449
- throw new DateTimeException("Unsupported field: " + field);
2450
- }
2451
- return field.getFrom(this);
2519
+ ZoneId.of = function of(zoneId) {
2520
+ throw new DateTimeException("not supported operation" + zoneId);
2452
2521
  };
2453
- _proto.query = function query(_query) {
2454
- requireNonNull(_query, 'query');
2455
- if (_query === TemporalQueries.offset() || _query === TemporalQueries.zone()) {
2456
- return this;
2457
- } else if (_query === TemporalQueries.localDate() || _query === TemporalQueries.localTime() || _query === TemporalQueries.precision() || _query === TemporalQueries.chronology() || _query === TemporalQueries.zoneId()) {
2458
- return null;
2459
- }
2460
- return _query.queryFrom(this);
2522
+ ZoneId.ofOffset = function ofOffset(prefix, offset) {
2523
+ throw new DateTimeException("not supported operation" + prefix + offset);
2461
2524
  };
2462
- _proto.adjustInto = function adjustInto(temporal) {
2463
- return temporal.with(ChronoField.OFFSET_SECONDS, this._totalSeconds);
2525
+ ZoneId.from = function from(temporal) {
2526
+ throw new DateTimeException("not supported operation" + temporal);
2464
2527
  };
2465
- _proto.compareTo = function compareTo(other) {
2466
- requireNonNull(other, 'other');
2467
- return other._totalSeconds - this._totalSeconds;
2528
+ var _proto = ZoneId.prototype;
2529
+ _proto.id = function id() {
2530
+ abstractMethodFail('ZoneId.id');
2468
2531
  };
2469
- _proto.equals = function equals(obj) {
2470
- if (this === obj) {
2532
+ _proto.rules = function rules() {
2533
+ abstractMethodFail('ZoneId.rules');
2534
+ };
2535
+ _proto.normalized = function normalized() {
2536
+ var rules = this.rules();
2537
+ if (rules.isFixedOffset()) {
2538
+ return rules.offset(Instant.EPOCH);
2539
+ }
2540
+ return this;
2541
+ };
2542
+ _proto.equals = function equals(other) {
2543
+ if (this === other) {
2471
2544
  return true;
2472
2545
  }
2473
- if (obj instanceof ZoneOffset) {
2474
- return this._totalSeconds === obj._totalSeconds;
2546
+ if (other instanceof ZoneId) {
2547
+ return this.id() === other.id();
2475
2548
  }
2476
2549
  return false;
2477
2550
  };
2478
2551
  _proto.hashCode = function hashCode() {
2479
- return this._totalSeconds;
2552
+ return StringUtil.hashCode(this.id());
2480
2553
  };
2481
2554
  _proto.toString = function toString() {
2482
- return this._id;
2555
+ return this.id();
2483
2556
  };
2484
- return ZoneOffset;
2485
- }(ZoneId);
2486
- function _init$g() {
2487
- ZoneOffset.MAX_SECONDS = 18 * LocalTime.SECONDS_PER_HOUR;
2488
- ZoneOffset.UTC = ZoneOffset.ofTotalSeconds(0);
2489
- ZoneOffset.MIN = ZoneOffset.ofTotalSeconds(-ZoneOffset.MAX_SECONDS);
2490
- ZoneOffset.MAX = ZoneOffset.ofTotalSeconds(ZoneOffset.MAX_SECONDS);
2491
- }
2557
+ _proto.toJSON = function toJSON() {
2558
+ return this.toString();
2559
+ };
2560
+ return ZoneId;
2561
+ }();
2492
2562
 
2493
- var DateTimeBuilder = function (_TemporalAccessor) {
2494
- function DateTimeBuilder() {
2495
- var _this;
2496
- _this = _TemporalAccessor.call(this) || this;
2497
- _this.fieldValues = new EnumMap();
2498
- _this.chrono = null;
2499
- _this.zone = null;
2500
- _this.date = null;
2501
- _this.time = null;
2502
- _this.leapSecond = false;
2503
- _this.excessDays = null;
2504
- return _this;
2505
- }
2506
- _inheritsLoose(DateTimeBuilder, _TemporalAccessor);
2507
- DateTimeBuilder.create = function create(field, value) {
2508
- var dtb = new DateTimeBuilder();
2509
- dtb._addFieldValue(field, value);
2510
- return dtb;
2563
+ var ZoneRules = function () {
2564
+ function ZoneRules() {}
2565
+ ZoneRules.of = function of(offset) {
2566
+ requireNonNull(offset, 'offset');
2567
+ return new Fixed(offset);
2511
2568
  };
2512
- var _proto = DateTimeBuilder.prototype;
2513
- _proto.getFieldValue0 = function getFieldValue0(field) {
2514
- return this.fieldValues.get(field);
2569
+ var _proto = ZoneRules.prototype;
2570
+ _proto.isFixedOffset = function isFixedOffset() {
2571
+ abstractMethodFail('ZoneRules.isFixedOffset');
2515
2572
  };
2516
- _proto._addFieldValue = function _addFieldValue(field, value) {
2517
- requireNonNull(field, 'field');
2518
- var old = this.getFieldValue0(field);
2519
- if (old != null && old !== value) {
2520
- throw new DateTimeException("Conflict found: " + field + " " + old + " differs from " + field + " " + value + ": " + this);
2573
+ _proto.offset = function offset(instantOrLocalDateTime) {
2574
+ if (instantOrLocalDateTime instanceof Instant) {
2575
+ return this.offsetOfInstant(instantOrLocalDateTime);
2576
+ } else {
2577
+ return this.offsetOfLocalDateTime(instantOrLocalDateTime);
2521
2578
  }
2522
- return this._putFieldValue0(field, value);
2523
2579
  };
2524
- _proto._putFieldValue0 = function _putFieldValue0(field, value) {
2525
- this.fieldValues.put(field, value);
2526
- return this;
2580
+ _proto.offsetOfInstant = function offsetOfInstant(instant) {
2581
+ abstractMethodFail('ZoneRules.offsetInstant');
2527
2582
  };
2528
- _proto.resolve = function resolve(resolverStyle, resolverFields) {
2529
- if (resolverFields != null) {
2530
- this.fieldValues.retainAll(resolverFields);
2583
+ _proto.offsetOfEpochMilli = function offsetOfEpochMilli(epochMilli) {
2584
+ abstractMethodFail('ZoneRules.offsetOfEpochMilli');
2585
+ };
2586
+ _proto.offsetOfLocalDateTime = function offsetOfLocalDateTime(localDateTime) {
2587
+ abstractMethodFail('ZoneRules.offsetLocalDateTime');
2588
+ };
2589
+ _proto.validOffsets = function validOffsets(localDateTime) {
2590
+ abstractMethodFail('ZoneRules.validOffsets');
2591
+ };
2592
+ _proto.transition = function transition(localDateTime) {
2593
+ abstractMethodFail('ZoneRules.transition');
2594
+ };
2595
+ _proto.standardOffset = function standardOffset(instant) {
2596
+ abstractMethodFail('ZoneRules.standardOffset');
2597
+ };
2598
+ _proto.daylightSavings = function daylightSavings(instant) {
2599
+ abstractMethodFail('ZoneRules.daylightSavings');
2600
+ };
2601
+ _proto.isDaylightSavings = function isDaylightSavings(instant) {
2602
+ abstractMethodFail('ZoneRules.isDaylightSavings');
2603
+ };
2604
+ _proto.isValidOffset = function isValidOffset(localDateTime, offset) {
2605
+ abstractMethodFail('ZoneRules.isValidOffset');
2606
+ };
2607
+ _proto.nextTransition = function nextTransition(instant) {
2608
+ abstractMethodFail('ZoneRules.nextTransition');
2609
+ };
2610
+ _proto.previousTransition = function previousTransition(instant) {
2611
+ abstractMethodFail('ZoneRules.previousTransition');
2612
+ };
2613
+ _proto.transitions = function transitions() {
2614
+ abstractMethodFail('ZoneRules.transitions');
2615
+ };
2616
+ _proto.transitionRules = function transitionRules() {
2617
+ abstractMethodFail('ZoneRules.transitionRules');
2618
+ };
2619
+ _proto.toString = function toString() {
2620
+ abstractMethodFail('ZoneRules.toString');
2621
+ };
2622
+ _proto.toJSON = function toJSON() {
2623
+ return this.toString();
2624
+ };
2625
+ return ZoneRules;
2626
+ }();
2627
+ var Fixed = function (_ZoneRules) {
2628
+ function Fixed(offset) {
2629
+ var _this;
2630
+ _this = _ZoneRules.call(this) || this;
2631
+ _this._offset = offset;
2632
+ return _this;
2633
+ }
2634
+ _inheritsLoose(Fixed, _ZoneRules);
2635
+ var _proto2 = Fixed.prototype;
2636
+ _proto2.isFixedOffset = function isFixedOffset() {
2637
+ return true;
2638
+ };
2639
+ _proto2.offsetOfInstant = function offsetOfInstant() {
2640
+ return this._offset;
2641
+ };
2642
+ _proto2.offsetOfEpochMilli = function offsetOfEpochMilli() {
2643
+ return this._offset;
2644
+ };
2645
+ _proto2.offsetOfLocalDateTime = function offsetOfLocalDateTime() {
2646
+ return this._offset;
2647
+ };
2648
+ _proto2.validOffsets = function validOffsets() {
2649
+ return [this._offset];
2650
+ };
2651
+ _proto2.transition = function transition() {
2652
+ return null;
2653
+ };
2654
+ _proto2.standardOffset = function standardOffset() {
2655
+ return this._offset;
2656
+ };
2657
+ _proto2.daylightSavings = function daylightSavings() {
2658
+ return Duration.ZERO;
2659
+ };
2660
+ _proto2.isDaylightSavings = function isDaylightSavings() {
2661
+ return false;
2662
+ };
2663
+ _proto2.isValidOffset = function isValidOffset(localDateTime, offset) {
2664
+ return this._offset.equals(offset);
2665
+ };
2666
+ _proto2.nextTransition = function nextTransition() {
2667
+ return null;
2668
+ };
2669
+ _proto2.previousTransition = function previousTransition() {
2670
+ return null;
2671
+ };
2672
+ _proto2.transitions = function transitions() {
2673
+ return [];
2674
+ };
2675
+ _proto2.transitionRules = function transitionRules() {
2676
+ return [];
2677
+ };
2678
+ _proto2.equals = function equals(other) {
2679
+ if (this === other) {
2680
+ return true;
2531
2681
  }
2532
- this._mergeDate(resolverStyle);
2533
- this._mergeTime(resolverStyle);
2534
- this._resolveTimeInferZeroes(resolverStyle);
2535
- if (this.excessDays != null && this.excessDays.isZero() === false && this.date != null && this.time != null) {
2536
- this.date = this.date.plus(this.excessDays);
2537
- this.excessDays = Period.ZERO;
2682
+ if (other instanceof Fixed) {
2683
+ return this._offset.equals(other._offset);
2538
2684
  }
2539
- this._resolveInstant();
2540
- return this;
2685
+ return false;
2541
2686
  };
2542
- _proto._mergeDate = function _mergeDate(resolverStyle) {
2543
- this._checkDate(IsoChronology.INSTANCE.resolveDate(this.fieldValues, resolverStyle));
2687
+ _proto2.toString = function toString() {
2688
+ return "FixedRules:" + this._offset.toString();
2544
2689
  };
2545
- _proto._checkDate = function _checkDate(date) {
2546
- if (date != null) {
2547
- this._addObject(date);
2548
- for (var fieldName in this.fieldValues.keySet()) {
2549
- var field = ChronoField.byName(fieldName);
2550
- if (field) {
2551
- if (this.fieldValues.get(field) !== undefined) {
2552
- if (field.isDateBased()) {
2553
- var val1 = void 0;
2554
- try {
2555
- val1 = date.getLong(field);
2556
- } catch (ex) {
2557
- if (ex instanceof DateTimeException) {
2558
- continue;
2559
- } else {
2560
- throw ex;
2561
- }
2562
- }
2563
- var val2 = this.fieldValues.get(field);
2564
- if (val1 !== val2) {
2565
- throw new DateTimeException("Conflict found: Field " + field + " " + val1 + " differs from " + field + " " + val2 + " derived from " + date);
2566
- }
2567
- }
2568
- }
2569
- }
2690
+ return Fixed;
2691
+ }(ZoneRules);
2692
+
2693
+ var SECONDS_CACHE = {};
2694
+ var ID_CACHE = {};
2695
+ var ZoneOffset = function (_ZoneId) {
2696
+ function ZoneOffset(totalSeconds) {
2697
+ var _this;
2698
+ _this = _ZoneId.call(this) || this;
2699
+ ZoneOffset._validateTotalSeconds(totalSeconds);
2700
+ _this._totalSeconds = MathUtil.safeToInt(totalSeconds);
2701
+ _this._rules = ZoneRules.of(_this);
2702
+ _this._id = ZoneOffset._buildId(totalSeconds);
2703
+ return _this;
2704
+ }
2705
+ _inheritsLoose(ZoneOffset, _ZoneId);
2706
+ var _proto = ZoneOffset.prototype;
2707
+ _proto.totalSeconds = function totalSeconds() {
2708
+ return this._totalSeconds;
2709
+ };
2710
+ _proto.id = function id() {
2711
+ return this._id;
2712
+ };
2713
+ ZoneOffset._buildId = function _buildId(totalSeconds) {
2714
+ if (totalSeconds === 0) {
2715
+ return 'Z';
2716
+ } else {
2717
+ var absTotalSeconds = Math.abs(totalSeconds);
2718
+ var absHours = MathUtil.intDiv(absTotalSeconds, LocalTime.SECONDS_PER_HOUR);
2719
+ var absMinutes = MathUtil.intMod(MathUtil.intDiv(absTotalSeconds, LocalTime.SECONDS_PER_MINUTE), LocalTime.MINUTES_PER_HOUR);
2720
+ var buf = "" + (totalSeconds < 0 ? '-' : '+') + (absHours < 10 ? '0' : '') + absHours + (absMinutes < 10 ? ':0' : ':') + absMinutes;
2721
+ var absSeconds = MathUtil.intMod(absTotalSeconds, LocalTime.SECONDS_PER_MINUTE);
2722
+ if (absSeconds !== 0) {
2723
+ buf += (absSeconds < 10 ? ':0' : ':') + absSeconds;
2570
2724
  }
2725
+ return buf;
2571
2726
  }
2572
2727
  };
2573
- _proto._mergeTime = function _mergeTime(resolverStyle) {
2574
- if (this.fieldValues.containsKey(ChronoField.CLOCK_HOUR_OF_DAY)) {
2575
- var ch = this.fieldValues.remove(ChronoField.CLOCK_HOUR_OF_DAY);
2576
- if (resolverStyle !== ResolverStyle.LENIENT) {
2577
- if (resolverStyle === ResolverStyle.SMART && ch === 0) ; else {
2578
- ChronoField.CLOCK_HOUR_OF_DAY.checkValidValue(ch);
2579
- }
2580
- }
2581
- this._addFieldValue(ChronoField.HOUR_OF_DAY, ch === 24 ? 0 : ch);
2728
+ ZoneOffset._validateTotalSeconds = function _validateTotalSeconds(totalSeconds) {
2729
+ if (Math.abs(totalSeconds) > ZoneOffset.MAX_SECONDS) {
2730
+ throw new DateTimeException('Zone offset not in valid range: -18:00 to +18:00');
2582
2731
  }
2583
- if (this.fieldValues.containsKey(ChronoField.CLOCK_HOUR_OF_AMPM)) {
2584
- var _ch = this.fieldValues.remove(ChronoField.CLOCK_HOUR_OF_AMPM);
2585
- if (resolverStyle !== ResolverStyle.LENIENT) {
2586
- if (resolverStyle === ResolverStyle.SMART && _ch === 0) ; else {
2587
- ChronoField.CLOCK_HOUR_OF_AMPM.checkValidValue(_ch);
2588
- }
2589
- }
2590
- this._addFieldValue(ChronoField.HOUR_OF_AMPM, _ch === 12 ? 0 : _ch);
2732
+ };
2733
+ ZoneOffset._validate = function _validate(hours, minutes, seconds) {
2734
+ if (hours < -18 || hours > 18) {
2735
+ throw new DateTimeException("Zone offset hours not in valid range: value " + hours + " is not in the range -18 to 18");
2591
2736
  }
2592
- if (resolverStyle !== ResolverStyle.LENIENT) {
2593
- if (this.fieldValues.containsKey(ChronoField.AMPM_OF_DAY)) {
2594
- ChronoField.AMPM_OF_DAY.checkValidValue(this.fieldValues.get(ChronoField.AMPM_OF_DAY));
2737
+ if (hours > 0) {
2738
+ if (minutes < 0 || seconds < 0) {
2739
+ throw new DateTimeException('Zone offset minutes and seconds must be positive because hours is positive');
2595
2740
  }
2596
- if (this.fieldValues.containsKey(ChronoField.HOUR_OF_AMPM)) {
2597
- ChronoField.HOUR_OF_AMPM.checkValidValue(this.fieldValues.get(ChronoField.HOUR_OF_AMPM));
2741
+ } else if (hours < 0) {
2742
+ if (minutes > 0 || seconds > 0) {
2743
+ throw new DateTimeException('Zone offset minutes and seconds must be negative because hours is negative');
2598
2744
  }
2745
+ } else if (minutes > 0 && seconds < 0 || minutes < 0 && seconds > 0) {
2746
+ throw new DateTimeException('Zone offset minutes and seconds must have the same sign');
2599
2747
  }
2600
- if (this.fieldValues.containsKey(ChronoField.AMPM_OF_DAY) && this.fieldValues.containsKey(ChronoField.HOUR_OF_AMPM)) {
2601
- var ap = this.fieldValues.remove(ChronoField.AMPM_OF_DAY);
2602
- var hap = this.fieldValues.remove(ChronoField.HOUR_OF_AMPM);
2603
- this._addFieldValue(ChronoField.HOUR_OF_DAY, ap * 12 + hap);
2748
+ if (Math.abs(minutes) > 59) {
2749
+ throw new DateTimeException("Zone offset minutes not in valid range: abs(value) " + Math.abs(minutes) + " is not in the range 0 to 59");
2604
2750
  }
2605
- if (this.fieldValues.containsKey(ChronoField.NANO_OF_DAY)) {
2606
- var nod = this.fieldValues.remove(ChronoField.NANO_OF_DAY);
2607
- if (resolverStyle !== ResolverStyle.LENIENT) {
2608
- ChronoField.NANO_OF_DAY.checkValidValue(nod);
2609
- }
2610
- this._addFieldValue(ChronoField.SECOND_OF_DAY, MathUtil.intDiv(nod, 1000000000));
2611
- this._addFieldValue(ChronoField.NANO_OF_SECOND, MathUtil.intMod(nod, 1000000000));
2612
- }
2613
- if (this.fieldValues.containsKey(ChronoField.MICRO_OF_DAY)) {
2614
- var cod = this.fieldValues.remove(ChronoField.MICRO_OF_DAY);
2615
- if (resolverStyle !== ResolverStyle.LENIENT) {
2616
- ChronoField.MICRO_OF_DAY.checkValidValue(cod);
2617
- }
2618
- this._addFieldValue(ChronoField.SECOND_OF_DAY, MathUtil.intDiv(cod, 1000000));
2619
- this._addFieldValue(ChronoField.MICRO_OF_SECOND, MathUtil.intMod(cod, 1000000));
2620
- }
2621
- if (this.fieldValues.containsKey(ChronoField.MILLI_OF_DAY)) {
2622
- var lod = this.fieldValues.remove(ChronoField.MILLI_OF_DAY);
2623
- if (resolverStyle !== ResolverStyle.LENIENT) {
2624
- ChronoField.MILLI_OF_DAY.checkValidValue(lod);
2625
- }
2626
- this._addFieldValue(ChronoField.SECOND_OF_DAY, MathUtil.intDiv(lod, 1000));
2627
- this._addFieldValue(ChronoField.MILLI_OF_SECOND, MathUtil.intMod(lod, 1000));
2628
- }
2629
- if (this.fieldValues.containsKey(ChronoField.SECOND_OF_DAY)) {
2630
- var sod = this.fieldValues.remove(ChronoField.SECOND_OF_DAY);
2631
- if (resolverStyle !== ResolverStyle.LENIENT) {
2632
- ChronoField.SECOND_OF_DAY.checkValidValue(sod);
2633
- }
2634
- this._addFieldValue(ChronoField.HOUR_OF_DAY, MathUtil.intDiv(sod, 3600));
2635
- this._addFieldValue(ChronoField.MINUTE_OF_HOUR, MathUtil.intMod(MathUtil.intDiv(sod, 60), 60));
2636
- this._addFieldValue(ChronoField.SECOND_OF_MINUTE, MathUtil.intMod(sod, 60));
2637
- }
2638
- if (this.fieldValues.containsKey(ChronoField.MINUTE_OF_DAY)) {
2639
- var mod = this.fieldValues.remove(ChronoField.MINUTE_OF_DAY);
2640
- if (resolverStyle !== ResolverStyle.LENIENT) {
2641
- ChronoField.MINUTE_OF_DAY.checkValidValue(mod);
2642
- }
2643
- this._addFieldValue(ChronoField.HOUR_OF_DAY, MathUtil.intDiv(mod, 60));
2644
- this._addFieldValue(ChronoField.MINUTE_OF_HOUR, MathUtil.intMod(mod, 60));
2751
+ if (Math.abs(seconds) > 59) {
2752
+ throw new DateTimeException("Zone offset seconds not in valid range: abs(value) " + Math.abs(seconds) + " is not in the range 0 to 59");
2645
2753
  }
2646
- if (resolverStyle !== ResolverStyle.LENIENT) {
2647
- if (this.fieldValues.containsKey(ChronoField.MILLI_OF_SECOND)) {
2648
- ChronoField.MILLI_OF_SECOND.checkValidValue(this.fieldValues.get(ChronoField.MILLI_OF_SECOND));
2649
- }
2650
- if (this.fieldValues.containsKey(ChronoField.MICRO_OF_SECOND)) {
2651
- ChronoField.MICRO_OF_SECOND.checkValidValue(this.fieldValues.get(ChronoField.MICRO_OF_SECOND));
2652
- }
2754
+ if (Math.abs(hours) === 18 && (Math.abs(minutes) > 0 || Math.abs(seconds) > 0)) {
2755
+ throw new DateTimeException('Zone offset not in valid range: -18:00 to +18:00');
2653
2756
  }
2654
- if (this.fieldValues.containsKey(ChronoField.MILLI_OF_SECOND) && this.fieldValues.containsKey(ChronoField.MICRO_OF_SECOND)) {
2655
- var los = this.fieldValues.remove(ChronoField.MILLI_OF_SECOND);
2656
- var cos = this.fieldValues.get(ChronoField.MICRO_OF_SECOND);
2657
- this._putFieldValue0(ChronoField.MICRO_OF_SECOND, los * 1000 + MathUtil.intMod(cos, 1000));
2757
+ };
2758
+ ZoneOffset.of = function of(offsetId) {
2759
+ requireNonNull(offsetId, 'offsetId');
2760
+ var offset = ID_CACHE[offsetId];
2761
+ if (offset != null) {
2762
+ return offset;
2658
2763
  }
2659
- if (this.fieldValues.containsKey(ChronoField.MICRO_OF_SECOND) && this.fieldValues.containsKey(ChronoField.NANO_OF_SECOND)) {
2660
- var nos = this.fieldValues.get(ChronoField.NANO_OF_SECOND);
2661
- this._putFieldValue0(ChronoField.MICRO_OF_SECOND, MathUtil.intDiv(nos, 1000));
2662
- this.fieldValues.remove(ChronoField.MICRO_OF_SECOND);
2764
+ var hours, minutes, seconds;
2765
+ switch (offsetId.length) {
2766
+ case 2:
2767
+ offsetId = offsetId[0] + "0" + offsetId[1];
2768
+ case 3:
2769
+ hours = ZoneOffset._parseNumber(offsetId, 1, false);
2770
+ minutes = 0;
2771
+ seconds = 0;
2772
+ break;
2773
+ case 5:
2774
+ hours = ZoneOffset._parseNumber(offsetId, 1, false);
2775
+ minutes = ZoneOffset._parseNumber(offsetId, 3, false);
2776
+ seconds = 0;
2777
+ break;
2778
+ case 6:
2779
+ hours = ZoneOffset._parseNumber(offsetId, 1, false);
2780
+ minutes = ZoneOffset._parseNumber(offsetId, 4, true);
2781
+ seconds = 0;
2782
+ break;
2783
+ case 7:
2784
+ hours = ZoneOffset._parseNumber(offsetId, 1, false);
2785
+ minutes = ZoneOffset._parseNumber(offsetId, 3, false);
2786
+ seconds = ZoneOffset._parseNumber(offsetId, 5, false);
2787
+ break;
2788
+ case 9:
2789
+ hours = ZoneOffset._parseNumber(offsetId, 1, false);
2790
+ minutes = ZoneOffset._parseNumber(offsetId, 4, true);
2791
+ seconds = ZoneOffset._parseNumber(offsetId, 7, true);
2792
+ break;
2793
+ default:
2794
+ throw new DateTimeException("Invalid ID for ZoneOffset, invalid format: " + offsetId);
2663
2795
  }
2664
- if (this.fieldValues.containsKey(ChronoField.MILLI_OF_SECOND) && this.fieldValues.containsKey(ChronoField.NANO_OF_SECOND)) {
2665
- var _nos = this.fieldValues.get(ChronoField.NANO_OF_SECOND);
2666
- this._putFieldValue0(ChronoField.MILLI_OF_SECOND, MathUtil.intDiv(_nos, 1000000));
2667
- this.fieldValues.remove(ChronoField.MILLI_OF_SECOND);
2796
+ var first = offsetId[0];
2797
+ if (first !== '+' && first !== '-') {
2798
+ throw new DateTimeException("Invalid ID for ZoneOffset, plus/minus not found when expected: " + offsetId);
2668
2799
  }
2669
- if (this.fieldValues.containsKey(ChronoField.MICRO_OF_SECOND)) {
2670
- var _cos = this.fieldValues.remove(ChronoField.MICRO_OF_SECOND);
2671
- this._putFieldValue0(ChronoField.NANO_OF_SECOND, _cos * 1000);
2672
- } else if (this.fieldValues.containsKey(ChronoField.MILLI_OF_SECOND)) {
2673
- var _los = this.fieldValues.remove(ChronoField.MILLI_OF_SECOND);
2674
- this._putFieldValue0(ChronoField.NANO_OF_SECOND, _los * 1000000);
2800
+ if (first === '-') {
2801
+ return ZoneOffset.ofHoursMinutesSeconds(-hours, -minutes, -seconds);
2802
+ } else {
2803
+ return ZoneOffset.ofHoursMinutesSeconds(hours, minutes, seconds);
2675
2804
  }
2676
2805
  };
2677
- _proto._resolveTimeInferZeroes = function _resolveTimeInferZeroes(resolverStyle) {
2678
- var hod = this.fieldValues.get(ChronoField.HOUR_OF_DAY);
2679
- var moh = this.fieldValues.get(ChronoField.MINUTE_OF_HOUR);
2680
- var som = this.fieldValues.get(ChronoField.SECOND_OF_MINUTE);
2681
- var nos = this.fieldValues.get(ChronoField.NANO_OF_SECOND);
2682
- if (hod == null) {
2683
- return;
2684
- }
2685
- if (moh == null && (som != null || nos != null)) {
2686
- return;
2806
+ ZoneOffset._parseNumber = function _parseNumber(offsetId, pos, precededByColon) {
2807
+ if (precededByColon && offsetId[pos - 1] !== ':') {
2808
+ throw new DateTimeException("Invalid ID for ZoneOffset, colon not found when expected: " + offsetId);
2687
2809
  }
2688
- if (moh != null && som == null && nos != null) {
2689
- return;
2810
+ var ch1 = offsetId[pos];
2811
+ var ch2 = offsetId[pos + 1];
2812
+ if (ch1 < '0' || ch1 > '9' || ch2 < '0' || ch2 > '9') {
2813
+ throw new DateTimeException("Invalid ID for ZoneOffset, non numeric characters found: " + offsetId);
2690
2814
  }
2691
- if (resolverStyle !== ResolverStyle.LENIENT) {
2692
- if (hod != null) {
2693
- if (resolverStyle === ResolverStyle.SMART && hod === 24 && (moh == null || moh === 0) && (som == null || som === 0) && (nos == null || nos === 0)) {
2694
- hod = 0;
2695
- this.excessDays = Period.ofDays(1);
2696
- }
2697
- var hodVal = ChronoField.HOUR_OF_DAY.checkValidIntValue(hod);
2698
- if (moh != null) {
2699
- var mohVal = ChronoField.MINUTE_OF_HOUR.checkValidIntValue(moh);
2700
- if (som != null) {
2701
- var somVal = ChronoField.SECOND_OF_MINUTE.checkValidIntValue(som);
2702
- if (nos != null) {
2703
- var nosVal = ChronoField.NANO_OF_SECOND.checkValidIntValue(nos);
2704
- this._addObject(LocalTime.of(hodVal, mohVal, somVal, nosVal));
2705
- } else {
2706
- this._addObject(LocalTime.of(hodVal, mohVal, somVal));
2707
- }
2708
- } else {
2709
- if (nos == null) {
2710
- this._addObject(LocalTime.of(hodVal, mohVal));
2711
- }
2712
- }
2713
- } else {
2714
- if (som == null && nos == null) {
2715
- this._addObject(LocalTime.of(hodVal, 0));
2716
- }
2717
- }
2815
+ return (ch1.charCodeAt(0) - 48) * 10 + (ch2.charCodeAt(0) - 48);
2816
+ };
2817
+ ZoneOffset.ofHours = function ofHours(hours) {
2818
+ return ZoneOffset.ofHoursMinutesSeconds(hours, 0, 0);
2819
+ };
2820
+ ZoneOffset.ofHoursMinutes = function ofHoursMinutes(hours, minutes) {
2821
+ return ZoneOffset.ofHoursMinutesSeconds(hours, minutes, 0);
2822
+ };
2823
+ ZoneOffset.ofHoursMinutesSeconds = function ofHoursMinutesSeconds(hours, minutes, seconds) {
2824
+ ZoneOffset._validate(hours, minutes, seconds);
2825
+ var totalSeconds = hours * LocalTime.SECONDS_PER_HOUR + minutes * LocalTime.SECONDS_PER_MINUTE + seconds;
2826
+ return ZoneOffset.ofTotalSeconds(totalSeconds);
2827
+ };
2828
+ ZoneOffset.ofTotalMinutes = function ofTotalMinutes(totalMinutes) {
2829
+ var totalSeconds = totalMinutes * LocalTime.SECONDS_PER_MINUTE;
2830
+ return ZoneOffset.ofTotalSeconds(totalSeconds);
2831
+ };
2832
+ ZoneOffset.ofTotalSeconds = function ofTotalSeconds(totalSeconds) {
2833
+ if (totalSeconds % (15 * LocalTime.SECONDS_PER_MINUTE) === 0) {
2834
+ var totalSecs = totalSeconds;
2835
+ var result = SECONDS_CACHE[totalSecs];
2836
+ if (result == null) {
2837
+ result = new ZoneOffset(totalSeconds);
2838
+ SECONDS_CACHE[totalSecs] = result;
2839
+ ID_CACHE[result.id()] = result;
2718
2840
  }
2841
+ return result;
2719
2842
  } else {
2720
- if (hod != null) {
2721
- var _hodVal = hod;
2722
- if (moh != null) {
2723
- if (som != null) {
2724
- if (nos == null) {
2725
- nos = 0;
2726
- }
2727
- var totalNanos = MathUtil.safeMultiply(_hodVal, 3600000000000);
2728
- totalNanos = MathUtil.safeAdd(totalNanos, MathUtil.safeMultiply(moh, 60000000000));
2729
- totalNanos = MathUtil.safeAdd(totalNanos, MathUtil.safeMultiply(som, 1000000000));
2730
- totalNanos = MathUtil.safeAdd(totalNanos, nos);
2731
- var excessDays = MathUtil.floorDiv(totalNanos, 86400000000000);
2732
- var nod = MathUtil.floorMod(totalNanos, 86400000000000);
2733
- this._addObject(LocalTime.ofNanoOfDay(nod));
2734
- this.excessDays = Period.ofDays(excessDays);
2735
- } else {
2736
- var totalSecs = MathUtil.safeMultiply(_hodVal, 3600);
2737
- totalSecs = MathUtil.safeAdd(totalSecs, MathUtil.safeMultiply(moh, 60));
2738
- var _excessDays = MathUtil.floorDiv(totalSecs, 86400);
2739
- var sod = MathUtil.floorMod(totalSecs, 86400);
2740
- this._addObject(LocalTime.ofSecondOfDay(sod));
2741
- this.excessDays = Period.ofDays(_excessDays);
2742
- }
2743
- } else {
2744
- var _excessDays2 = MathUtil.safeToInt(MathUtil.floorDiv(_hodVal, 24));
2745
- _hodVal = MathUtil.floorMod(_hodVal, 24);
2746
- this._addObject(LocalTime.of(_hodVal, 0));
2747
- this.excessDays = Period.ofDays(_excessDays2);
2748
- }
2749
- }
2843
+ return new ZoneOffset(totalSeconds);
2750
2844
  }
2751
- this.fieldValues.remove(ChronoField.HOUR_OF_DAY);
2752
- this.fieldValues.remove(ChronoField.MINUTE_OF_HOUR);
2753
- this.fieldValues.remove(ChronoField.SECOND_OF_MINUTE);
2754
- this.fieldValues.remove(ChronoField.NANO_OF_SECOND);
2755
2845
  };
2756
- _proto._addObject = function _addObject(dateOrTime) {
2757
- if (dateOrTime instanceof ChronoLocalDate) {
2758
- this.date = dateOrTime;
2759
- } else if (dateOrTime instanceof LocalTime) {
2760
- this.time = dateOrTime;
2761
- }
2846
+ _proto.rules = function rules() {
2847
+ return this._rules;
2762
2848
  };
2763
- _proto._resolveInstant = function _resolveInstant() {
2764
- if (this.date != null && this.time != null) {
2765
- var offsetSecs = this.fieldValues.get(ChronoField.OFFSET_SECONDS);
2766
- if (offsetSecs != null) {
2767
- var offset = ZoneOffset.ofTotalSeconds(offsetSecs);
2768
- var instant = this.date.atTime(this.time).atZone(offset).getLong(ChronoField.INSTANT_SECONDS);
2769
- this.fieldValues.put(ChronoField.INSTANT_SECONDS, instant);
2770
- } else if (this.zone != null) {
2771
- var _instant = this.date.atTime(this.time).atZone(this.zone).getLong(ChronoField.INSTANT_SECONDS);
2772
- this.fieldValues.put(ChronoField.INSTANT_SECONDS, _instant);
2773
- }
2774
- }
2849
+ _proto.get = function get(field) {
2850
+ return this.getLong(field);
2775
2851
  };
2776
- _proto.build = function build(type) {
2777
- return type.queryFrom(this);
2852
+ _proto.getLong = function getLong(field) {
2853
+ if (field === ChronoField.OFFSET_SECONDS) {
2854
+ return this._totalSeconds;
2855
+ } else if (field instanceof ChronoField) {
2856
+ throw new DateTimeException("Unsupported field: " + field);
2857
+ }
2858
+ return field.getFrom(this);
2778
2859
  };
2779
- _proto.isSupported = function isSupported(field) {
2780
- if (field == null) {
2781
- return false;
2860
+ _proto.query = function query(_query) {
2861
+ requireNonNull(_query, 'query');
2862
+ if (_query === TemporalQueries.offset() || _query === TemporalQueries.zone()) {
2863
+ return this;
2864
+ } else if (_query === TemporalQueries.localDate() || _query === TemporalQueries.localTime() || _query === TemporalQueries.precision() || _query === TemporalQueries.chronology() || _query === TemporalQueries.zoneId()) {
2865
+ return null;
2782
2866
  }
2783
- return this.fieldValues.containsKey(field) && this.fieldValues.get(field) !== undefined || this.date != null && this.date.isSupported(field) || this.time != null && this.time.isSupported(field);
2867
+ return _query.queryFrom(this);
2784
2868
  };
2785
- _proto.getLong = function getLong(field) {
2786
- requireNonNull(field, 'field');
2787
- var value = this.getFieldValue0(field);
2788
- if (value == null) {
2789
- if (this.date != null && this.date.isSupported(field)) {
2790
- return this.date.getLong(field);
2791
- }
2792
- if (this.time != null && this.time.isSupported(field)) {
2793
- return this.time.getLong(field);
2794
- }
2795
- throw new DateTimeException("Field not found: " + field);
2796
- }
2797
- return value;
2798
- };
2799
- _proto.query = function query(_query) {
2800
- if (_query === TemporalQueries.zoneId()) {
2801
- return this.zone;
2802
- } else if (_query === TemporalQueries.chronology()) {
2803
- return this.chrono;
2804
- } else if (_query === TemporalQueries.localDate()) {
2805
- return this.date != null ? LocalDate.from(this.date) : null;
2806
- } else if (_query === TemporalQueries.localTime()) {
2807
- return this.time;
2808
- } else if (_query === TemporalQueries.zone() || _query === TemporalQueries.offset()) {
2809
- return _query.queryFrom(this);
2810
- } else if (_query === TemporalQueries.precision()) {
2811
- return null;
2812
- }
2813
- return _query.queryFrom(this);
2814
- };
2815
- return DateTimeBuilder;
2816
- }(TemporalAccessor);
2817
-
2818
- var DateTimeParseContext = function () {
2819
- function DateTimeParseContext() {
2820
- if (arguments.length === 1) {
2821
- if (arguments[0] instanceof DateTimeParseContext) {
2822
- this._constructorSelf.apply(this, arguments);
2823
- return;
2824
- } else {
2825
- this._constructorFormatter.apply(this, arguments);
2826
- }
2827
- } else {
2828
- this._constructorParam.apply(this, arguments);
2829
- }
2830
- this._caseSensitive = true;
2831
- this._strict = true;
2832
- this._parsed = [new Parsed(this)];
2833
- }
2834
- var _proto = DateTimeParseContext.prototype;
2835
- _proto._constructorParam = function _constructorParam(locale, symbols, chronology) {
2836
- this._locale = locale;
2837
- this._symbols = symbols;
2838
- this._overrideChronology = chronology;
2839
- };
2840
- _proto._constructorFormatter = function _constructorFormatter(formatter) {
2841
- this._locale = formatter.locale();
2842
- this._symbols = formatter.decimalStyle();
2843
- this._overrideChronology = formatter.chronology();
2844
- };
2845
- _proto._constructorSelf = function _constructorSelf(other) {
2846
- this._locale = other._locale;
2847
- this._symbols = other._symbols;
2848
- this._overrideChronology = other._overrideChronology;
2849
- this._overrideZone = other._overrideZone;
2850
- this._caseSensitive = other._caseSensitive;
2851
- this._strict = other._strict;
2852
- this._parsed = [new Parsed(this)];
2853
- };
2854
- _proto.copy = function copy() {
2855
- return new DateTimeParseContext(this);
2856
- };
2857
- _proto.symbols = function symbols() {
2858
- return this._symbols;
2859
- };
2860
- _proto.isStrict = function isStrict() {
2861
- return this._strict;
2862
- };
2863
- _proto.setStrict = function setStrict(strict) {
2864
- this._strict = strict;
2865
- };
2866
- _proto.locale = function locale() {
2867
- return this._locale;
2868
- };
2869
- _proto.setLocale = function setLocale(locale) {
2870
- this._locale = locale;
2871
- };
2872
- _proto.startOptional = function startOptional() {
2873
- this._parsed.push(this.currentParsed().copy());
2874
- };
2875
- _proto.endOptional = function endOptional(successful) {
2876
- if (successful) {
2877
- this._parsed.splice(this._parsed.length - 2, 1);
2878
- } else {
2879
- this._parsed.splice(this._parsed.length - 1, 1);
2880
- }
2881
- };
2882
- _proto.isCaseSensitive = function isCaseSensitive() {
2883
- return this._caseSensitive;
2869
+ _proto.adjustInto = function adjustInto(temporal) {
2870
+ return temporal.with(ChronoField.OFFSET_SECONDS, this._totalSeconds);
2884
2871
  };
2885
- _proto.setCaseSensitive = function setCaseSensitive(caseSensitive) {
2886
- this._caseSensitive = caseSensitive;
2872
+ _proto.compareTo = function compareTo(other) {
2873
+ requireNonNull(other, 'other');
2874
+ return other._totalSeconds - this._totalSeconds;
2887
2875
  };
2888
- _proto.subSequenceEquals = function subSequenceEquals(cs1, offset1, cs2, offset2, length) {
2889
- if (offset1 + length > cs1.length || offset2 + length > cs2.length) {
2890
- return false;
2891
- }
2892
- if (!this.isCaseSensitive()) {
2893
- cs1 = cs1.toLowerCase();
2894
- cs2 = cs2.toLowerCase();
2895
- }
2896
- for (var i = 0; i < length; i++) {
2897
- var ch1 = cs1[offset1 + i];
2898
- var ch2 = cs2[offset2 + i];
2899
- if (ch1 !== ch2) {
2900
- return false;
2901
- }
2876
+ _proto.equals = function equals(obj) {
2877
+ if (this === obj) {
2878
+ return true;
2902
2879
  }
2903
- return true;
2904
- };
2905
- _proto.charEquals = function charEquals(ch1, ch2) {
2906
- if (this.isCaseSensitive()) {
2907
- return ch1 === ch2;
2880
+ if (obj instanceof ZoneOffset) {
2881
+ return this._totalSeconds === obj._totalSeconds;
2908
2882
  }
2909
- return this.charEqualsIgnoreCase(ch1, ch2);
2910
- };
2911
- _proto.charEqualsIgnoreCase = function charEqualsIgnoreCase(c1, c2) {
2912
- return c1 === c2 || c1.toLowerCase() === c2.toLowerCase();
2913
- };
2914
- _proto.setParsedField = function setParsedField(field, value, errorPos, successPos) {
2915
- var currentParsedFieldValues = this.currentParsed().fieldValues;
2916
- var old = currentParsedFieldValues.get(field);
2917
- currentParsedFieldValues.set(field, value);
2918
- return old != null && old !== value ? ~errorPos : successPos;
2919
- };
2920
- _proto.setParsedZone = function setParsedZone(zone) {
2921
- requireNonNull(zone, 'zone');
2922
- this.currentParsed().zone = zone;
2923
- };
2924
- _proto.getParsed = function getParsed(field) {
2925
- return this.currentParsed().fieldValues.get(field);
2926
- };
2927
- _proto.toParsed = function toParsed() {
2928
- return this.currentParsed();
2929
- };
2930
- _proto.currentParsed = function currentParsed() {
2931
- return this._parsed[this._parsed.length - 1];
2883
+ return false;
2932
2884
  };
2933
- _proto.setParsedLeapSecond = function setParsedLeapSecond() {
2934
- this.currentParsed().leapSecond = true;
2885
+ _proto.hashCode = function hashCode() {
2886
+ return this._totalSeconds;
2935
2887
  };
2936
- _proto.getEffectiveChronology = function getEffectiveChronology() {
2937
- var chrono = this.currentParsed().chrono;
2938
- if (chrono == null) {
2939
- chrono = this._overrideChronology;
2940
- if (chrono == null) {
2941
- chrono = IsoChronology.INSTANCE;
2942
- }
2943
- }
2944
- return chrono;
2888
+ _proto.toString = function toString() {
2889
+ return this._id;
2945
2890
  };
2946
- return DateTimeParseContext;
2947
- }();
2948
- var Parsed = function (_Temporal) {
2949
- function Parsed(dateTimeParseContext) {
2891
+ return ZoneOffset;
2892
+ }(ZoneId);
2893
+ function _init$f() {
2894
+ ZoneOffset.MAX_SECONDS = 18 * LocalTime.SECONDS_PER_HOUR;
2895
+ ZoneOffset.UTC = ZoneOffset.ofTotalSeconds(0);
2896
+ ZoneOffset.MIN = ZoneOffset.ofTotalSeconds(-ZoneOffset.MAX_SECONDS);
2897
+ ZoneOffset.MAX = ZoneOffset.ofTotalSeconds(ZoneOffset.MAX_SECONDS);
2898
+ }
2899
+
2900
+ var DateTimeBuilder = function (_TemporalAccessor) {
2901
+ function DateTimeBuilder() {
2950
2902
  var _this;
2951
- _this = _Temporal.call(this) || this;
2903
+ _this = _TemporalAccessor.call(this) || this;
2904
+ _this.fieldValues = new EnumMap();
2952
2905
  _this.chrono = null;
2953
2906
  _this.zone = null;
2954
- _this.fieldValues = new EnumMap();
2907
+ _this.date = null;
2908
+ _this.time = null;
2955
2909
  _this.leapSecond = false;
2956
- _this.dateTimeParseContext = dateTimeParseContext;
2910
+ _this.excessDays = null;
2957
2911
  return _this;
2958
2912
  }
2959
- _inheritsLoose(Parsed, _Temporal);
2960
- var _proto2 = Parsed.prototype;
2961
- _proto2.copy = function copy() {
2962
- var cloned = new Parsed();
2963
- cloned.chrono = this.chrono;
2964
- cloned.zone = this.zone;
2965
- cloned.fieldValues.putAll(this.fieldValues);
2966
- cloned.leapSecond = this.leapSecond;
2967
- cloned.dateTimeParseContext = this.dateTimeParseContext;
2968
- return cloned;
2913
+ _inheritsLoose(DateTimeBuilder, _TemporalAccessor);
2914
+ DateTimeBuilder.create = function create(field, value) {
2915
+ var dtb = new DateTimeBuilder();
2916
+ dtb._addFieldValue(field, value);
2917
+ return dtb;
2969
2918
  };
2970
- _proto2.toString = function toString() {
2971
- return this.fieldValues + ", " + this.chrono + ", " + this.zone;
2919
+ var _proto = DateTimeBuilder.prototype;
2920
+ _proto.getFieldValue0 = function getFieldValue0(field) {
2921
+ return this.fieldValues.get(field);
2972
2922
  };
2973
- _proto2.isSupported = function isSupported(field) {
2974
- return this.fieldValues.containsKey(field);
2923
+ _proto._addFieldValue = function _addFieldValue(field, value) {
2924
+ requireNonNull(field, 'field');
2925
+ var old = this.getFieldValue0(field);
2926
+ if (old != null && old !== value) {
2927
+ throw new DateTimeException("Conflict found: " + field + " " + old + " differs from " + field + " " + value + ": " + this);
2928
+ }
2929
+ return this._putFieldValue0(field, value);
2975
2930
  };
2976
- _proto2.get = function get(field) {
2977
- var val = this.fieldValues.get(field);
2978
- assert(val != null);
2979
- return val;
2931
+ _proto._putFieldValue0 = function _putFieldValue0(field, value) {
2932
+ this.fieldValues.put(field, value);
2933
+ return this;
2980
2934
  };
2981
- _proto2.query = function query(_query) {
2982
- if (_query === TemporalQueries.chronology()) {
2983
- return this.chrono;
2935
+ _proto.resolve = function resolve(resolverStyle, resolverFields) {
2936
+ if (resolverFields != null) {
2937
+ this.fieldValues.retainAll(resolverFields);
2984
2938
  }
2985
- if (_query === TemporalQueries.zoneId() || _query === TemporalQueries.zone()) {
2986
- return this.zone;
2939
+ if (this._resolveFields(resolverStyle)) ;
2940
+ this._mergeDate(resolverStyle);
2941
+ this._mergeTime(resolverStyle);
2942
+ this._resolveTimeInferZeroes(resolverStyle);
2943
+ if (this.excessDays != null && this.excessDays.isZero() === false && this.date != null && this.time != null) {
2944
+ this.date = this.date.plus(this.excessDays);
2945
+ this.excessDays = Period.ZERO;
2987
2946
  }
2988
- return _Temporal.prototype.query.call(this, _query);
2947
+ this._resolveInstant();
2948
+ return this;
2989
2949
  };
2990
- _proto2.toBuilder = function toBuilder() {
2991
- var builder = new DateTimeBuilder();
2992
- builder.fieldValues.putAll(this.fieldValues);
2993
- builder.chrono = this.dateTimeParseContext.getEffectiveChronology();
2994
- if (this.zone != null) {
2995
- builder.zone = this.zone;
2996
- } else {
2997
- builder.zone = this.overrideZone;
2950
+ _proto._resolveFields = function _resolveFields(resolverStyle) {
2951
+ var resolved = false;
2952
+ for (var _i = 0, _arr = [IsoFields.WEEK_OF_WEEK_BASED_YEAR, IsoFields.DAY_OF_QUARTER]; _i < _arr.length; _i++) {
2953
+ var field = _arr[_i];
2954
+ if (this.fieldValues.containsKey(field)) {
2955
+ var date = field.resolve(this.fieldValues, this, resolverStyle);
2956
+ if (date != null) {
2957
+ this._checkDate(date);
2958
+ resolved = true;
2959
+ }
2960
+ }
2998
2961
  }
2999
- builder.leapSecond = this.leapSecond;
3000
- builder.excessDays = this.excessDays;
3001
- return builder;
2962
+ return resolved;
3002
2963
  };
3003
- return Parsed;
3004
- }(Temporal);
3005
-
3006
- /*
3007
- * @copyright (c) 2016, Philipp Thürwächter & Pattrick Hüper
3008
- * @copyright (c) 2007-present, Stephen Colebourne & Michael Nascimento Santos
3009
- * @license BSD-3-Clause (see LICENSE in the root directory of this source tree)
3010
- */
3011
-
3012
- var DateTimePrintContext = function () {
3013
- function DateTimePrintContext(temporal, localeOrFormatter, symbols) {
3014
- if (arguments.length === 2 && arguments[1] instanceof DateTimeFormatter) {
3015
- this._temporal = DateTimePrintContext.adjust(temporal, localeOrFormatter);
3016
- this._locale = localeOrFormatter.locale();
3017
- this._symbols = localeOrFormatter.decimalStyle();
3018
- } else {
3019
- this._temporal = temporal;
3020
- this._locale = localeOrFormatter;
3021
- this._symbols = symbols;
3022
- }
3023
- this._optional = 0;
3024
- }
3025
- DateTimePrintContext.adjust = function adjust(temporal, formatter) {
3026
- return temporal;
3027
- };
3028
- var _proto = DateTimePrintContext.prototype;
3029
- _proto.symbols = function symbols() {
3030
- return this._symbols;
3031
- };
3032
- _proto.startOptional = function startOptional() {
3033
- this._optional++;
3034
- };
3035
- _proto.endOptional = function endOptional() {
3036
- this._optional--;
2964
+ _proto._mergeDate = function _mergeDate(resolverStyle) {
2965
+ this._checkDate(IsoChronology.INSTANCE.resolveDate(this.fieldValues, resolverStyle));
3037
2966
  };
3038
- _proto.getValueQuery = function getValueQuery(query) {
3039
- var result = this._temporal.query(query);
3040
- if (result == null && this._optional === 0) {
3041
- throw new DateTimeException("Unable to extract value: " + this._temporal);
2967
+ _proto._checkDate = function _checkDate(date) {
2968
+ if (date != null) {
2969
+ this._addObject(date);
2970
+ for (var fieldName in this.fieldValues.keySet()) {
2971
+ var field = ChronoField.byName(fieldName);
2972
+ if (field) {
2973
+ if (this.fieldValues.get(field) !== undefined) {
2974
+ if (field.isDateBased()) {
2975
+ var val1 = void 0;
2976
+ try {
2977
+ val1 = date.getLong(field);
2978
+ } catch (ex) {
2979
+ if (ex instanceof DateTimeException) {
2980
+ continue;
2981
+ } else {
2982
+ throw ex;
2983
+ }
2984
+ }
2985
+ var val2 = this.fieldValues.get(field);
2986
+ if (val1 !== val2) {
2987
+ throw new DateTimeException("Conflict found: Field " + field + " " + val1 + " differs from " + field + " " + val2 + " derived from " + date);
2988
+ }
2989
+ }
2990
+ }
2991
+ }
2992
+ }
3042
2993
  }
3043
- return result;
3044
2994
  };
3045
- _proto.getValue = function getValue(field) {
3046
- try {
3047
- return this._temporal.getLong(field);
3048
- } catch (ex) {
3049
- if (ex instanceof DateTimeException && this._optional > 0) {
3050
- return null;
2995
+ _proto._mergeTime = function _mergeTime(resolverStyle) {
2996
+ if (this.fieldValues.containsKey(ChronoField.CLOCK_HOUR_OF_DAY)) {
2997
+ var ch = this.fieldValues.remove(ChronoField.CLOCK_HOUR_OF_DAY);
2998
+ if (resolverStyle !== ResolverStyle.LENIENT) {
2999
+ if (resolverStyle === ResolverStyle.SMART && ch === 0) ; else {
3000
+ ChronoField.CLOCK_HOUR_OF_DAY.checkValidValue(ch);
3001
+ }
3051
3002
  }
3052
- throw ex;
3003
+ this._addFieldValue(ChronoField.HOUR_OF_DAY, ch === 24 ? 0 : ch);
3053
3004
  }
3054
- };
3055
- _proto.temporal = function temporal() {
3056
- return this._temporal;
3057
- };
3058
- _proto.locale = function locale() {
3059
- return this._locale;
3060
- };
3061
- _proto.setDateTime = function setDateTime(temporal) {
3062
- this._temporal = temporal;
3063
- };
3064
- _proto.setLocale = function setLocale(locale) {
3065
- this._locale = locale;
3066
- };
3067
- return DateTimePrintContext;
3068
- }();
3069
-
3070
- var IsoFields = {};
3071
- var QUARTER_DAYS = [0, 90, 181, 273, 0, 91, 182, 274];
3072
- var Field = function (_TemporalField) {
3073
- function Field() {
3074
- return _TemporalField.apply(this, arguments) || this;
3075
- }
3076
- _inheritsLoose(Field, _TemporalField);
3077
- var _proto = Field.prototype;
3078
- _proto.isDateBased = function isDateBased() {
3079
- return true;
3080
- };
3081
- _proto.isTimeBased = function isTimeBased() {
3082
- return false;
3083
- };
3084
- _proto._isIso = function _isIso() {
3085
- return true;
3086
- };
3087
- Field._getWeekRangeByLocalDate = function _getWeekRangeByLocalDate(date) {
3088
- var wby = Field._getWeekBasedYear(date);
3089
- return ValueRange.of(1, Field._getWeekRangeByYear(wby));
3090
- };
3091
- Field._getWeekRangeByYear = function _getWeekRangeByYear(wby) {
3092
- var date = LocalDate.of(wby, 1, 1);
3093
- if (date.dayOfWeek() === DayOfWeek.THURSDAY || date.dayOfWeek() === DayOfWeek.WEDNESDAY && date.isLeapYear()) {
3094
- return 53;
3005
+ if (this.fieldValues.containsKey(ChronoField.CLOCK_HOUR_OF_AMPM)) {
3006
+ var _ch = this.fieldValues.remove(ChronoField.CLOCK_HOUR_OF_AMPM);
3007
+ if (resolverStyle !== ResolverStyle.LENIENT) {
3008
+ if (resolverStyle === ResolverStyle.SMART && _ch === 0) ; else {
3009
+ ChronoField.CLOCK_HOUR_OF_AMPM.checkValidValue(_ch);
3010
+ }
3011
+ }
3012
+ this._addFieldValue(ChronoField.HOUR_OF_AMPM, _ch === 12 ? 0 : _ch);
3095
3013
  }
3096
- return 52;
3097
- };
3098
- Field._getWeek = function _getWeek(date) {
3099
- var dow0 = date.dayOfWeek().ordinal();
3100
- var doy0 = date.dayOfYear() - 1;
3101
- var doyThu0 = doy0 + (3 - dow0);
3102
- var alignedWeek = MathUtil.intDiv(doyThu0, 7);
3103
- var firstThuDoy0 = doyThu0 - alignedWeek * 7;
3104
- var firstMonDoy0 = firstThuDoy0 - 3;
3105
- if (firstMonDoy0 < -3) {
3106
- firstMonDoy0 += 7;
3014
+ if (resolverStyle !== ResolverStyle.LENIENT) {
3015
+ if (this.fieldValues.containsKey(ChronoField.AMPM_OF_DAY)) {
3016
+ ChronoField.AMPM_OF_DAY.checkValidValue(this.fieldValues.get(ChronoField.AMPM_OF_DAY));
3017
+ }
3018
+ if (this.fieldValues.containsKey(ChronoField.HOUR_OF_AMPM)) {
3019
+ ChronoField.HOUR_OF_AMPM.checkValidValue(this.fieldValues.get(ChronoField.HOUR_OF_AMPM));
3020
+ }
3107
3021
  }
3108
- if (doy0 < firstMonDoy0) {
3109
- return Field._getWeekRangeByLocalDate(date.withDayOfYear(180).minusYears(1)).maximum();
3022
+ if (this.fieldValues.containsKey(ChronoField.AMPM_OF_DAY) && this.fieldValues.containsKey(ChronoField.HOUR_OF_AMPM)) {
3023
+ var ap = this.fieldValues.remove(ChronoField.AMPM_OF_DAY);
3024
+ var hap = this.fieldValues.remove(ChronoField.HOUR_OF_AMPM);
3025
+ this._addFieldValue(ChronoField.HOUR_OF_DAY, ap * 12 + hap);
3110
3026
  }
3111
- var week = MathUtil.intDiv(doy0 - firstMonDoy0, 7) + 1;
3112
- if (week === 53) {
3113
- if ((firstMonDoy0 === -3 || firstMonDoy0 === -2 && date.isLeapYear()) === false) {
3114
- week = 1;
3027
+ if (this.fieldValues.containsKey(ChronoField.NANO_OF_DAY)) {
3028
+ var nod = this.fieldValues.remove(ChronoField.NANO_OF_DAY);
3029
+ if (resolverStyle !== ResolverStyle.LENIENT) {
3030
+ ChronoField.NANO_OF_DAY.checkValidValue(nod);
3115
3031
  }
3032
+ this._addFieldValue(ChronoField.SECOND_OF_DAY, MathUtil.intDiv(nod, 1000000000));
3033
+ this._addFieldValue(ChronoField.NANO_OF_SECOND, MathUtil.intMod(nod, 1000000000));
3116
3034
  }
3117
- return week;
3118
- };
3119
- Field._getWeekBasedYear = function _getWeekBasedYear(date) {
3120
- var year = date.year();
3121
- var doy = date.dayOfYear();
3122
- if (doy <= 3) {
3123
- var dow = date.dayOfWeek().ordinal();
3124
- if (doy - dow < -2) {
3125
- year--;
3035
+ if (this.fieldValues.containsKey(ChronoField.MICRO_OF_DAY)) {
3036
+ var cod = this.fieldValues.remove(ChronoField.MICRO_OF_DAY);
3037
+ if (resolverStyle !== ResolverStyle.LENIENT) {
3038
+ ChronoField.MICRO_OF_DAY.checkValidValue(cod);
3126
3039
  }
3127
- } else if (doy >= 363) {
3128
- var _dow = date.dayOfWeek().ordinal();
3129
- doy = doy - 363 - (date.isLeapYear() ? 1 : 0);
3130
- if (doy - _dow >= 0) {
3131
- year++;
3040
+ this._addFieldValue(ChronoField.SECOND_OF_DAY, MathUtil.intDiv(cod, 1000000));
3041
+ this._addFieldValue(ChronoField.MICRO_OF_SECOND, MathUtil.intMod(cod, 1000000));
3042
+ }
3043
+ if (this.fieldValues.containsKey(ChronoField.MILLI_OF_DAY)) {
3044
+ var lod = this.fieldValues.remove(ChronoField.MILLI_OF_DAY);
3045
+ if (resolverStyle !== ResolverStyle.LENIENT) {
3046
+ ChronoField.MILLI_OF_DAY.checkValidValue(lod);
3132
3047
  }
3048
+ this._addFieldValue(ChronoField.SECOND_OF_DAY, MathUtil.intDiv(lod, 1000));
3049
+ this._addFieldValue(ChronoField.MILLI_OF_SECOND, MathUtil.intMod(lod, 1000));
3050
+ }
3051
+ if (this.fieldValues.containsKey(ChronoField.SECOND_OF_DAY)) {
3052
+ var sod = this.fieldValues.remove(ChronoField.SECOND_OF_DAY);
3053
+ if (resolverStyle !== ResolverStyle.LENIENT) {
3054
+ ChronoField.SECOND_OF_DAY.checkValidValue(sod);
3055
+ }
3056
+ this._addFieldValue(ChronoField.HOUR_OF_DAY, MathUtil.intDiv(sod, 3600));
3057
+ this._addFieldValue(ChronoField.MINUTE_OF_HOUR, MathUtil.intMod(MathUtil.intDiv(sod, 60), 60));
3058
+ this._addFieldValue(ChronoField.SECOND_OF_MINUTE, MathUtil.intMod(sod, 60));
3059
+ }
3060
+ if (this.fieldValues.containsKey(ChronoField.MINUTE_OF_DAY)) {
3061
+ var mod = this.fieldValues.remove(ChronoField.MINUTE_OF_DAY);
3062
+ if (resolverStyle !== ResolverStyle.LENIENT) {
3063
+ ChronoField.MINUTE_OF_DAY.checkValidValue(mod);
3064
+ }
3065
+ this._addFieldValue(ChronoField.HOUR_OF_DAY, MathUtil.intDiv(mod, 60));
3066
+ this._addFieldValue(ChronoField.MINUTE_OF_HOUR, MathUtil.intMod(mod, 60));
3067
+ }
3068
+ if (resolverStyle !== ResolverStyle.LENIENT) {
3069
+ if (this.fieldValues.containsKey(ChronoField.MILLI_OF_SECOND)) {
3070
+ ChronoField.MILLI_OF_SECOND.checkValidValue(this.fieldValues.get(ChronoField.MILLI_OF_SECOND));
3071
+ }
3072
+ if (this.fieldValues.containsKey(ChronoField.MICRO_OF_SECOND)) {
3073
+ ChronoField.MICRO_OF_SECOND.checkValidValue(this.fieldValues.get(ChronoField.MICRO_OF_SECOND));
3074
+ }
3075
+ }
3076
+ if (this.fieldValues.containsKey(ChronoField.MILLI_OF_SECOND) && this.fieldValues.containsKey(ChronoField.MICRO_OF_SECOND)) {
3077
+ var los = this.fieldValues.remove(ChronoField.MILLI_OF_SECOND);
3078
+ var cos = this.fieldValues.get(ChronoField.MICRO_OF_SECOND);
3079
+ this._putFieldValue0(ChronoField.MICRO_OF_SECOND, los * 1000 + MathUtil.intMod(cos, 1000));
3080
+ }
3081
+ if (this.fieldValues.containsKey(ChronoField.MICRO_OF_SECOND) && this.fieldValues.containsKey(ChronoField.NANO_OF_SECOND)) {
3082
+ var nos = this.fieldValues.get(ChronoField.NANO_OF_SECOND);
3083
+ this._putFieldValue0(ChronoField.MICRO_OF_SECOND, MathUtil.intDiv(nos, 1000));
3084
+ this.fieldValues.remove(ChronoField.MICRO_OF_SECOND);
3085
+ }
3086
+ if (this.fieldValues.containsKey(ChronoField.MILLI_OF_SECOND) && this.fieldValues.containsKey(ChronoField.NANO_OF_SECOND)) {
3087
+ var _nos = this.fieldValues.get(ChronoField.NANO_OF_SECOND);
3088
+ this._putFieldValue0(ChronoField.MILLI_OF_SECOND, MathUtil.intDiv(_nos, 1000000));
3089
+ this.fieldValues.remove(ChronoField.MILLI_OF_SECOND);
3090
+ }
3091
+ if (this.fieldValues.containsKey(ChronoField.MICRO_OF_SECOND)) {
3092
+ var _cos = this.fieldValues.remove(ChronoField.MICRO_OF_SECOND);
3093
+ this._putFieldValue0(ChronoField.NANO_OF_SECOND, _cos * 1000);
3094
+ } else if (this.fieldValues.containsKey(ChronoField.MILLI_OF_SECOND)) {
3095
+ var _los = this.fieldValues.remove(ChronoField.MILLI_OF_SECOND);
3096
+ this._putFieldValue0(ChronoField.NANO_OF_SECOND, _los * 1000000);
3133
3097
  }
3134
- return year;
3135
- };
3136
- _proto.displayName = function displayName() {
3137
- return this.toString();
3138
- };
3139
- _proto.resolve = function resolve() {
3140
- return null;
3141
- };
3142
- _proto.name = function name() {
3143
- return this.toString();
3144
- };
3145
- return Field;
3146
- }(TemporalField);
3147
- var DAY_OF_QUARTER_FIELD = function (_Field) {
3148
- function DAY_OF_QUARTER_FIELD() {
3149
- return _Field.apply(this, arguments) || this;
3150
- }
3151
- _inheritsLoose(DAY_OF_QUARTER_FIELD, _Field);
3152
- var _proto2 = DAY_OF_QUARTER_FIELD.prototype;
3153
- _proto2.toString = function toString() {
3154
- return 'DayOfQuarter';
3155
- };
3156
- _proto2.baseUnit = function baseUnit() {
3157
- return ChronoUnit.DAYS;
3158
- };
3159
- _proto2.rangeUnit = function rangeUnit() {
3160
- return QUARTER_YEARS;
3161
- };
3162
- _proto2.range = function range() {
3163
- return ValueRange.of(1, 90, 92);
3164
3098
  };
3165
- _proto2.isSupportedBy = function isSupportedBy(temporal) {
3166
- return temporal.isSupported(ChronoField.DAY_OF_YEAR) && temporal.isSupported(ChronoField.MONTH_OF_YEAR) && temporal.isSupported(ChronoField.YEAR) && this._isIso(temporal);
3099
+ _proto._resolveTimeInferZeroes = function _resolveTimeInferZeroes(resolverStyle) {
3100
+ var hod = this.fieldValues.get(ChronoField.HOUR_OF_DAY);
3101
+ var moh = this.fieldValues.get(ChronoField.MINUTE_OF_HOUR);
3102
+ var som = this.fieldValues.get(ChronoField.SECOND_OF_MINUTE);
3103
+ var nos = this.fieldValues.get(ChronoField.NANO_OF_SECOND);
3104
+ if (hod == null) {
3105
+ return;
3106
+ }
3107
+ if (moh == null && (som != null || nos != null)) {
3108
+ return;
3109
+ }
3110
+ if (moh != null && som == null && nos != null) {
3111
+ return;
3112
+ }
3113
+ if (resolverStyle !== ResolverStyle.LENIENT) {
3114
+ if (hod != null) {
3115
+ if (resolverStyle === ResolverStyle.SMART && hod === 24 && (moh == null || moh === 0) && (som == null || som === 0) && (nos == null || nos === 0)) {
3116
+ hod = 0;
3117
+ this.excessDays = Period.ofDays(1);
3118
+ }
3119
+ var hodVal = ChronoField.HOUR_OF_DAY.checkValidIntValue(hod);
3120
+ if (moh != null) {
3121
+ var mohVal = ChronoField.MINUTE_OF_HOUR.checkValidIntValue(moh);
3122
+ if (som != null) {
3123
+ var somVal = ChronoField.SECOND_OF_MINUTE.checkValidIntValue(som);
3124
+ if (nos != null) {
3125
+ var nosVal = ChronoField.NANO_OF_SECOND.checkValidIntValue(nos);
3126
+ this._addObject(LocalTime.of(hodVal, mohVal, somVal, nosVal));
3127
+ } else {
3128
+ this._addObject(LocalTime.of(hodVal, mohVal, somVal));
3129
+ }
3130
+ } else {
3131
+ if (nos == null) {
3132
+ this._addObject(LocalTime.of(hodVal, mohVal));
3133
+ }
3134
+ }
3135
+ } else {
3136
+ if (som == null && nos == null) {
3137
+ this._addObject(LocalTime.of(hodVal, 0));
3138
+ }
3139
+ }
3140
+ }
3141
+ } else {
3142
+ if (hod != null) {
3143
+ var _hodVal = hod;
3144
+ if (moh != null) {
3145
+ if (som != null) {
3146
+ if (nos == null) {
3147
+ nos = 0;
3148
+ }
3149
+ var totalNanos = MathUtil.safeMultiply(_hodVal, 3600000000000);
3150
+ totalNanos = MathUtil.safeAdd(totalNanos, MathUtil.safeMultiply(moh, 60000000000));
3151
+ totalNanos = MathUtil.safeAdd(totalNanos, MathUtil.safeMultiply(som, 1000000000));
3152
+ totalNanos = MathUtil.safeAdd(totalNanos, nos);
3153
+ var excessDays = MathUtil.floorDiv(totalNanos, 86400000000000);
3154
+ var nod = MathUtil.floorMod(totalNanos, 86400000000000);
3155
+ this._addObject(LocalTime.ofNanoOfDay(nod));
3156
+ this.excessDays = Period.ofDays(excessDays);
3157
+ } else {
3158
+ var totalSecs = MathUtil.safeMultiply(_hodVal, 3600);
3159
+ totalSecs = MathUtil.safeAdd(totalSecs, MathUtil.safeMultiply(moh, 60));
3160
+ var _excessDays = MathUtil.floorDiv(totalSecs, 86400);
3161
+ var sod = MathUtil.floorMod(totalSecs, 86400);
3162
+ this._addObject(LocalTime.ofSecondOfDay(sod));
3163
+ this.excessDays = Period.ofDays(_excessDays);
3164
+ }
3165
+ } else {
3166
+ var _excessDays2 = MathUtil.safeToInt(MathUtil.floorDiv(_hodVal, 24));
3167
+ _hodVal = MathUtil.floorMod(_hodVal, 24);
3168
+ this._addObject(LocalTime.of(_hodVal, 0));
3169
+ this.excessDays = Period.ofDays(_excessDays2);
3170
+ }
3171
+ }
3172
+ }
3173
+ this.fieldValues.remove(ChronoField.HOUR_OF_DAY);
3174
+ this.fieldValues.remove(ChronoField.MINUTE_OF_HOUR);
3175
+ this.fieldValues.remove(ChronoField.SECOND_OF_MINUTE);
3176
+ this.fieldValues.remove(ChronoField.NANO_OF_SECOND);
3167
3177
  };
3168
- _proto2.rangeRefinedBy = function rangeRefinedBy(temporal) {
3169
- if (temporal.isSupported(this) === false) {
3170
- throw new UnsupportedTemporalTypeException('Unsupported field: DayOfQuarter');
3178
+ _proto._addObject = function _addObject(dateOrTime) {
3179
+ if (dateOrTime instanceof ChronoLocalDate) {
3180
+ this.date = dateOrTime;
3181
+ } else if (dateOrTime instanceof LocalTime) {
3182
+ this.time = dateOrTime;
3171
3183
  }
3172
- var qoy = temporal.getLong(QUARTER_OF_YEAR);
3173
- if (qoy === 1) {
3174
- var year = temporal.getLong(ChronoField.YEAR);
3175
- return IsoChronology.isLeapYear(year) ? ValueRange.of(1, 91) : ValueRange.of(1, 90);
3176
- } else if (qoy === 2) {
3177
- return ValueRange.of(1, 91);
3178
- } else if (qoy === 3 || qoy === 4) {
3179
- return ValueRange.of(1, 92);
3184
+ };
3185
+ _proto._resolveInstant = function _resolveInstant() {
3186
+ if (this.date != null && this.time != null) {
3187
+ var offsetSecs = this.fieldValues.get(ChronoField.OFFSET_SECONDS);
3188
+ if (offsetSecs != null) {
3189
+ var offset = ZoneOffset.ofTotalSeconds(offsetSecs);
3190
+ var instant = this.date.atTime(this.time).atZone(offset).getLong(ChronoField.INSTANT_SECONDS);
3191
+ this.fieldValues.put(ChronoField.INSTANT_SECONDS, instant);
3192
+ } else if (this.zone != null) {
3193
+ var _instant = this.date.atTime(this.time).atZone(this.zone).getLong(ChronoField.INSTANT_SECONDS);
3194
+ this.fieldValues.put(ChronoField.INSTANT_SECONDS, _instant);
3195
+ }
3180
3196
  }
3181
- return this.range();
3182
3197
  };
3183
- _proto2.getFrom = function getFrom(temporal) {
3184
- if (temporal.isSupported(this) === false) {
3185
- throw new UnsupportedTemporalTypeException('Unsupported field: DayOfQuarter');
3198
+ _proto.build = function build(type) {
3199
+ return type.queryFrom(this);
3200
+ };
3201
+ _proto.isSupported = function isSupported(field) {
3202
+ if (field == null) {
3203
+ return false;
3186
3204
  }
3187
- var doy = temporal.get(ChronoField.DAY_OF_YEAR);
3188
- var moy = temporal.get(ChronoField.MONTH_OF_YEAR);
3189
- var year = temporal.getLong(ChronoField.YEAR);
3190
- return doy - QUARTER_DAYS[MathUtil.intDiv(moy - 1, 3) + (IsoChronology.isLeapYear(year) ? 4 : 0)];
3205
+ return this.fieldValues.containsKey(field) && this.fieldValues.get(field) !== undefined || this.date != null && this.date.isSupported(field) || this.time != null && this.time.isSupported(field);
3191
3206
  };
3192
- _proto2.adjustInto = function adjustInto(temporal, newValue) {
3193
- var curValue = this.getFrom(temporal);
3194
- this.range().checkValidValue(newValue, this);
3195
- return temporal.with(ChronoField.DAY_OF_YEAR, temporal.getLong(ChronoField.DAY_OF_YEAR) + (newValue - curValue));
3207
+ _proto.getLong = function getLong(field) {
3208
+ requireNonNull(field, 'field');
3209
+ var value = this.getFieldValue0(field);
3210
+ if (value == null) {
3211
+ if (this.date != null && this.date.isSupported(field)) {
3212
+ return this.date.getLong(field);
3213
+ }
3214
+ if (this.time != null && this.time.isSupported(field)) {
3215
+ return this.time.getLong(field);
3216
+ }
3217
+ throw new DateTimeException("Field not found: " + field);
3218
+ }
3219
+ return value;
3196
3220
  };
3197
- _proto2.resolve = function resolve(fieldValues, partialTemporal, resolverStyle) {
3198
- var yearLong = fieldValues.get(ChronoField.YEAR);
3199
- var qoyLong = fieldValues.get(QUARTER_OF_YEAR);
3200
- if (yearLong == null || qoyLong == null) {
3221
+ _proto.query = function query(_query) {
3222
+ if (_query === TemporalQueries.zoneId()) {
3223
+ return this.zone;
3224
+ } else if (_query === TemporalQueries.chronology()) {
3225
+ return this.chrono;
3226
+ } else if (_query === TemporalQueries.localDate()) {
3227
+ return this.date != null ? LocalDate.from(this.date) : null;
3228
+ } else if (_query === TemporalQueries.localTime()) {
3229
+ return this.time;
3230
+ } else if (_query === TemporalQueries.zone() || _query === TemporalQueries.offset()) {
3231
+ return _query.queryFrom(this);
3232
+ } else if (_query === TemporalQueries.precision()) {
3201
3233
  return null;
3202
3234
  }
3203
- var y = ChronoField.YEAR.checkValidIntValue(yearLong);
3204
- var doq = fieldValues.get(DAY_OF_QUARTER);
3205
- var date;
3206
- if (resolverStyle === ResolverStyle.LENIENT) {
3207
- var qoy = qoyLong;
3208
- date = LocalDate.of(y, 1, 1);
3209
- date = date.plusMonths(MathUtil.safeMultiply(MathUtil.safeSubtract(qoy, 1), 3));
3210
- date = date.plusDays(MathUtil.safeSubtract(doq, 1));
3211
- } else {
3212
- var _qoy = QUARTER_OF_YEAR.range().checkValidIntValue(qoyLong, QUARTER_OF_YEAR);
3213
- if (resolverStyle === ResolverStyle.STRICT) {
3214
- var max = 92;
3215
- if (_qoy === 1) {
3216
- max = IsoChronology.isLeapYear(y) ? 91 : 90;
3217
- } else if (_qoy === 2) {
3218
- max = 91;
3219
- }
3220
- ValueRange.of(1, max).checkValidValue(doq, this);
3235
+ return _query.queryFrom(this);
3236
+ };
3237
+ return DateTimeBuilder;
3238
+ }(TemporalAccessor);
3239
+
3240
+ var DateTimeParseContext = function () {
3241
+ function DateTimeParseContext() {
3242
+ if (arguments.length === 1) {
3243
+ if (arguments[0] instanceof DateTimeParseContext) {
3244
+ this._constructorSelf.apply(this, arguments);
3245
+ return;
3221
3246
  } else {
3222
- this.range().checkValidValue(doq, this);
3247
+ this._constructorFormatter.apply(this, arguments);
3223
3248
  }
3224
- date = LocalDate.of(y, (_qoy - 1) * 3 + 1, 1).plusDays(doq - 1);
3249
+ } else {
3250
+ this._constructorParam.apply(this, arguments);
3225
3251
  }
3226
- fieldValues.remove(this);
3227
- fieldValues.remove(ChronoField.YEAR);
3228
- fieldValues.remove(QUARTER_OF_YEAR);
3229
- return date;
3230
- };
3231
- return DAY_OF_QUARTER_FIELD;
3232
- }(Field);
3233
- var QUARTER_OF_YEAR_FIELD = function (_Field2) {
3234
- function QUARTER_OF_YEAR_FIELD() {
3235
- return _Field2.apply(this, arguments) || this;
3252
+ this._caseSensitive = true;
3253
+ this._strict = true;
3254
+ this._parsed = [new Parsed(this)];
3236
3255
  }
3237
- _inheritsLoose(QUARTER_OF_YEAR_FIELD, _Field2);
3238
- var _proto3 = QUARTER_OF_YEAR_FIELD.prototype;
3239
- _proto3.toString = function toString() {
3240
- return 'QuarterOfYear';
3256
+ var _proto = DateTimeParseContext.prototype;
3257
+ _proto._constructorParam = function _constructorParam(locale, symbols, chronology) {
3258
+ this._locale = locale;
3259
+ this._symbols = symbols;
3260
+ this._overrideChronology = chronology;
3241
3261
  };
3242
- _proto3.baseUnit = function baseUnit() {
3243
- return QUARTER_YEARS;
3262
+ _proto._constructorFormatter = function _constructorFormatter(formatter) {
3263
+ this._locale = formatter.locale();
3264
+ this._symbols = formatter.decimalStyle();
3265
+ this._overrideChronology = formatter.chronology();
3244
3266
  };
3245
- _proto3.rangeUnit = function rangeUnit() {
3246
- return ChronoUnit.YEARS;
3267
+ _proto._constructorSelf = function _constructorSelf(other) {
3268
+ this._locale = other._locale;
3269
+ this._symbols = other._symbols;
3270
+ this._overrideChronology = other._overrideChronology;
3271
+ this._overrideZone = other._overrideZone;
3272
+ this._caseSensitive = other._caseSensitive;
3273
+ this._strict = other._strict;
3274
+ this._parsed = [new Parsed(this)];
3247
3275
  };
3248
- _proto3.range = function range() {
3249
- return ValueRange.of(1, 4);
3276
+ _proto.copy = function copy() {
3277
+ return new DateTimeParseContext(this);
3250
3278
  };
3251
- _proto3.isSupportedBy = function isSupportedBy(temporal) {
3252
- return temporal.isSupported(ChronoField.MONTH_OF_YEAR) && this._isIso(temporal);
3279
+ _proto.symbols = function symbols() {
3280
+ return this._symbols;
3253
3281
  };
3254
- _proto3.rangeRefinedBy = function rangeRefinedBy(temporal) {
3255
- return this.range();
3282
+ _proto.isStrict = function isStrict() {
3283
+ return this._strict;
3256
3284
  };
3257
- _proto3.getFrom = function getFrom(temporal) {
3258
- if (temporal.isSupported(this) === false) {
3259
- throw new UnsupportedTemporalTypeException('Unsupported field: QuarterOfYear');
3260
- }
3261
- var moy = temporal.getLong(ChronoField.MONTH_OF_YEAR);
3262
- return MathUtil.intDiv(moy + 2, 3);
3285
+ _proto.setStrict = function setStrict(strict) {
3286
+ this._strict = strict;
3263
3287
  };
3264
- _proto3.adjustInto = function adjustInto(temporal, newValue) {
3265
- var curValue = this.getFrom(temporal);
3266
- this.range().checkValidValue(newValue, this);
3267
- return temporal.with(ChronoField.MONTH_OF_YEAR, temporal.getLong(ChronoField.MONTH_OF_YEAR) + (newValue - curValue) * 3);
3288
+ _proto.locale = function locale() {
3289
+ return this._locale;
3268
3290
  };
3269
- return QUARTER_OF_YEAR_FIELD;
3270
- }(Field);
3271
- var WEEK_OF_WEEK_BASED_YEAR_FIELD = function (_Field3) {
3272
- function WEEK_OF_WEEK_BASED_YEAR_FIELD() {
3273
- return _Field3.apply(this, arguments) || this;
3274
- }
3275
- _inheritsLoose(WEEK_OF_WEEK_BASED_YEAR_FIELD, _Field3);
3276
- var _proto4 = WEEK_OF_WEEK_BASED_YEAR_FIELD.prototype;
3277
- _proto4.toString = function toString() {
3278
- return 'WeekOfWeekBasedYear';
3291
+ _proto.setLocale = function setLocale(locale) {
3292
+ this._locale = locale;
3279
3293
  };
3280
- _proto4.baseUnit = function baseUnit() {
3281
- return ChronoUnit.WEEKS;
3294
+ _proto.startOptional = function startOptional() {
3295
+ this._parsed.push(this.currentParsed().copy());
3282
3296
  };
3283
- _proto4.rangeUnit = function rangeUnit() {
3284
- return WEEK_BASED_YEARS;
3297
+ _proto.endOptional = function endOptional(successful) {
3298
+ if (successful) {
3299
+ this._parsed.splice(this._parsed.length - 2, 1);
3300
+ } else {
3301
+ this._parsed.splice(this._parsed.length - 1, 1);
3302
+ }
3285
3303
  };
3286
- _proto4.range = function range() {
3287
- return ValueRange.of(1, 52, 53);
3304
+ _proto.isCaseSensitive = function isCaseSensitive() {
3305
+ return this._caseSensitive;
3288
3306
  };
3289
- _proto4.isSupportedBy = function isSupportedBy(temporal) {
3290
- return temporal.isSupported(ChronoField.EPOCH_DAY) && this._isIso(temporal);
3307
+ _proto.setCaseSensitive = function setCaseSensitive(caseSensitive) {
3308
+ this._caseSensitive = caseSensitive;
3291
3309
  };
3292
- _proto4.rangeRefinedBy = function rangeRefinedBy(temporal) {
3293
- if (temporal.isSupported(this) === false) {
3294
- throw new UnsupportedTemporalTypeException('Unsupported field: WeekOfWeekBasedYear');
3310
+ _proto.subSequenceEquals = function subSequenceEquals(cs1, offset1, cs2, offset2, length) {
3311
+ if (offset1 + length > cs1.length || offset2 + length > cs2.length) {
3312
+ return false;
3295
3313
  }
3296
- return Field._getWeekRangeByLocalDate(LocalDate.from(temporal));
3314
+ if (!this.isCaseSensitive()) {
3315
+ cs1 = cs1.toLowerCase();
3316
+ cs2 = cs2.toLowerCase();
3317
+ }
3318
+ for (var i = 0; i < length; i++) {
3319
+ var ch1 = cs1[offset1 + i];
3320
+ var ch2 = cs2[offset2 + i];
3321
+ if (ch1 !== ch2) {
3322
+ return false;
3323
+ }
3324
+ }
3325
+ return true;
3297
3326
  };
3298
- _proto4.getFrom = function getFrom(temporal) {
3299
- if (temporal.isSupported(this) === false) {
3300
- throw new UnsupportedTemporalTypeException('Unsupported field: WeekOfWeekBasedYear');
3327
+ _proto.charEquals = function charEquals(ch1, ch2) {
3328
+ if (this.isCaseSensitive()) {
3329
+ return ch1 === ch2;
3301
3330
  }
3302
- return Field._getWeek(LocalDate.from(temporal));
3331
+ return this.charEqualsIgnoreCase(ch1, ch2);
3303
3332
  };
3304
- _proto4.adjustInto = function adjustInto(temporal, newValue) {
3305
- this.range().checkValidValue(newValue, this);
3306
- return temporal.plus(MathUtil.safeSubtract(newValue, this.getFrom(temporal)), ChronoUnit.WEEKS);
3333
+ _proto.charEqualsIgnoreCase = function charEqualsIgnoreCase(c1, c2) {
3334
+ return c1 === c2 || c1.toLowerCase() === c2.toLowerCase();
3307
3335
  };
3308
- _proto4.resolve = function resolve(fieldValues, partialTemporal, resolverStyle) {
3309
- var wbyLong = fieldValues.get(WEEK_BASED_YEAR);
3310
- var dowLong = fieldValues.get(ChronoField.DAY_OF_WEEK);
3311
- if (wbyLong == null || dowLong == null) {
3312
- return null;
3313
- }
3314
- var wby = WEEK_BASED_YEAR.range().checkValidIntValue(wbyLong, WEEK_BASED_YEAR);
3315
- var wowby = fieldValues.get(WEEK_OF_WEEK_BASED_YEAR);
3316
- var date;
3317
- if (resolverStyle === ResolverStyle.LENIENT) {
3318
- var dow = dowLong;
3319
- var weeks = 0;
3320
- if (dow > 7) {
3321
- weeks = MathUtil.intDiv(dow - 1, 7);
3322
- dow = MathUtil.intMod(dow - 1, 7) + 1;
3323
- } else if (dow < 1) {
3324
- weeks = MathUtil.intDiv(dow, 7) - 1;
3325
- dow = MathUtil.intMod(dow, 7) + 7;
3326
- }
3327
- date = LocalDate.of(wby, 1, 4).plusWeeks(wowby - 1).plusWeeks(weeks).with(ChronoField.DAY_OF_WEEK, dow);
3328
- } else {
3329
- var _dow2 = ChronoField.DAY_OF_WEEK.checkValidIntValue(dowLong);
3330
- if (resolverStyle === ResolverStyle.STRICT) {
3331
- var temp = LocalDate.of(wby, 1, 4);
3332
- var range = Field._getWeekRangeByLocalDate(temp);
3333
- range.checkValidValue(wowby, this);
3334
- } else {
3335
- this.range().checkValidValue(wowby, this);
3336
- }
3337
- date = LocalDate.of(wby, 1, 4).plusWeeks(wowby - 1).with(ChronoField.DAY_OF_WEEK, _dow2);
3338
- }
3339
- fieldValues.remove(this);
3340
- fieldValues.remove(WEEK_BASED_YEAR);
3341
- fieldValues.remove(ChronoField.DAY_OF_WEEK);
3342
- return date;
3336
+ _proto.setParsedField = function setParsedField(field, value, errorPos, successPos) {
3337
+ var currentParsedFieldValues = this.currentParsed().fieldValues;
3338
+ var old = currentParsedFieldValues.get(field);
3339
+ currentParsedFieldValues.set(field, value);
3340
+ return old != null && old !== value ? ~errorPos : successPos;
3343
3341
  };
3344
- _proto4.displayName = function displayName() {
3345
- return 'Week';
3342
+ _proto.setParsedZone = function setParsedZone(zone) {
3343
+ requireNonNull(zone, 'zone');
3344
+ this.currentParsed().zone = zone;
3346
3345
  };
3347
- return WEEK_OF_WEEK_BASED_YEAR_FIELD;
3348
- }(Field);
3349
- var WEEK_BASED_YEAR_FIELD = function (_Field4) {
3350
- function WEEK_BASED_YEAR_FIELD() {
3351
- return _Field4.apply(this, arguments) || this;
3352
- }
3353
- _inheritsLoose(WEEK_BASED_YEAR_FIELD, _Field4);
3354
- var _proto5 = WEEK_BASED_YEAR_FIELD.prototype;
3355
- _proto5.toString = function toString() {
3356
- return 'WeekBasedYear';
3346
+ _proto.getParsed = function getParsed(field) {
3347
+ return this.currentParsed().fieldValues.get(field);
3357
3348
  };
3358
- _proto5.baseUnit = function baseUnit() {
3359
- return WEEK_BASED_YEARS;
3349
+ _proto.toParsed = function toParsed() {
3350
+ return this.currentParsed();
3351
+ };
3352
+ _proto.currentParsed = function currentParsed() {
3353
+ return this._parsed[this._parsed.length - 1];
3354
+ };
3355
+ _proto.setParsedLeapSecond = function setParsedLeapSecond() {
3356
+ this.currentParsed().leapSecond = true;
3357
+ };
3358
+ _proto.getEffectiveChronology = function getEffectiveChronology() {
3359
+ var chrono = this.currentParsed().chrono;
3360
+ if (chrono == null) {
3361
+ chrono = this._overrideChronology;
3362
+ if (chrono == null) {
3363
+ chrono = IsoChronology.INSTANCE;
3364
+ }
3365
+ }
3366
+ return chrono;
3360
3367
  };
3361
- _proto5.rangeUnit = function rangeUnit() {
3362
- return ChronoUnit.FOREVER;
3368
+ return DateTimeParseContext;
3369
+ }();
3370
+ var Parsed = function (_Temporal) {
3371
+ function Parsed(dateTimeParseContext) {
3372
+ var _this;
3373
+ _this = _Temporal.call(this) || this;
3374
+ _this.chrono = null;
3375
+ _this.zone = null;
3376
+ _this.fieldValues = new EnumMap();
3377
+ _this.leapSecond = false;
3378
+ _this.excessDays = Period.ZERO;
3379
+ _this.dateTimeParseContext = dateTimeParseContext;
3380
+ return _this;
3381
+ }
3382
+ _inheritsLoose(Parsed, _Temporal);
3383
+ var _proto2 = Parsed.prototype;
3384
+ _proto2.copy = function copy() {
3385
+ var cloned = new Parsed();
3386
+ cloned.chrono = this.chrono;
3387
+ cloned.zone = this.zone;
3388
+ cloned.fieldValues.putAll(this.fieldValues);
3389
+ cloned.leapSecond = this.leapSecond;
3390
+ cloned.dateTimeParseContext = this.dateTimeParseContext;
3391
+ return cloned;
3363
3392
  };
3364
- _proto5.range = function range() {
3365
- return ChronoField.YEAR.range();
3393
+ _proto2.toString = function toString() {
3394
+ return this.fieldValues + ", " + this.chrono + ", " + this.zone;
3366
3395
  };
3367
- _proto5.isSupportedBy = function isSupportedBy(temporal) {
3368
- return temporal.isSupported(ChronoField.EPOCH_DAY) && this._isIso(temporal);
3396
+ _proto2.isSupported = function isSupported(field) {
3397
+ return this.fieldValues.containsKey(field);
3369
3398
  };
3370
- _proto5.rangeRefinedBy = function rangeRefinedBy(temporal) {
3371
- return ChronoField.YEAR.range();
3399
+ _proto2.get = function get(field) {
3400
+ var val = this.fieldValues.get(field);
3401
+ assert(val != null);
3402
+ return val;
3372
3403
  };
3373
- _proto5.getFrom = function getFrom(temporal) {
3374
- if (temporal.isSupported(this) === false) {
3375
- throw new UnsupportedTemporalTypeException('Unsupported field: WeekBasedYear');
3404
+ _proto2.query = function query(_query) {
3405
+ if (_query === TemporalQueries.chronology()) {
3406
+ return this.chrono;
3376
3407
  }
3377
- return Field._getWeekBasedYear(LocalDate.from(temporal));
3378
- };
3379
- _proto5.adjustInto = function adjustInto(temporal, newValue) {
3380
- if (this.isSupportedBy(temporal) === false) {
3381
- throw new UnsupportedTemporalTypeException('Unsupported field: WeekBasedYear');
3408
+ if (_query === TemporalQueries.zoneId() || _query === TemporalQueries.zone()) {
3409
+ return this.zone;
3382
3410
  }
3383
- var newWby = this.range().checkValidIntValue(newValue, WEEK_BASED_YEAR);
3384
- var date = LocalDate.from(temporal);
3385
- var dow = date.get(ChronoField.DAY_OF_WEEK);
3386
- var week = Field._getWeek(date);
3387
- if (week === 53 && Field._getWeekRangeByYear(newWby) === 52) {
3388
- week = 52;
3411
+ return _Temporal.prototype.query.call(this, _query);
3412
+ };
3413
+ _proto2.toBuilder = function toBuilder() {
3414
+ var builder = new DateTimeBuilder();
3415
+ builder.fieldValues.putAll(this.fieldValues);
3416
+ builder.chrono = this.dateTimeParseContext.getEffectiveChronology();
3417
+ if (this.zone != null) {
3418
+ builder.zone = this.zone;
3419
+ } else {
3420
+ builder.zone = this.overrideZone;
3389
3421
  }
3390
- var resolved = LocalDate.of(newWby, 1, 4);
3391
- var days = dow - resolved.get(ChronoField.DAY_OF_WEEK) + (week - 1) * 7;
3392
- resolved = resolved.plusDays(days);
3393
- return temporal.with(resolved);
3422
+ builder.leapSecond = this.leapSecond;
3423
+ builder.excessDays = this.excessDays;
3424
+ return builder;
3394
3425
  };
3395
- return WEEK_BASED_YEAR_FIELD;
3396
- }(Field);
3397
- var Unit = function (_TemporalUnit) {
3398
- function Unit(name, estimatedDuration) {
3399
- var _this;
3400
- _this = _TemporalUnit.call(this) || this;
3401
- _this._name = name;
3402
- _this._duration = estimatedDuration;
3403
- return _this;
3426
+ return Parsed;
3427
+ }(Temporal);
3428
+
3429
+ /*
3430
+ * @copyright (c) 2016, Philipp Thürwächter & Pattrick Hüper
3431
+ * @copyright (c) 2007-present, Stephen Colebourne & Michael Nascimento Santos
3432
+ * @license BSD-3-Clause (see LICENSE in the root directory of this source tree)
3433
+ */
3434
+
3435
+ var DateTimePrintContext = function () {
3436
+ function DateTimePrintContext(temporal, localeOrFormatter, symbols) {
3437
+ if (arguments.length === 2 && arguments[1] instanceof DateTimeFormatter) {
3438
+ this._temporal = DateTimePrintContext.adjust(temporal, localeOrFormatter);
3439
+ this._locale = localeOrFormatter.locale();
3440
+ this._symbols = localeOrFormatter.decimalStyle();
3441
+ } else {
3442
+ this._temporal = temporal;
3443
+ this._locale = localeOrFormatter;
3444
+ this._symbols = symbols;
3445
+ }
3446
+ this._optional = 0;
3404
3447
  }
3405
- _inheritsLoose(Unit, _TemporalUnit);
3406
- var _proto6 = Unit.prototype;
3407
- _proto6.duration = function duration() {
3408
- return this._duration;
3409
- };
3410
- _proto6.isDurationEstimated = function isDurationEstimated() {
3411
- return true;
3448
+ DateTimePrintContext.adjust = function adjust(temporal, formatter) {
3449
+ return temporal;
3412
3450
  };
3413
- _proto6.isDateBased = function isDateBased() {
3414
- return true;
3451
+ var _proto = DateTimePrintContext.prototype;
3452
+ _proto.symbols = function symbols() {
3453
+ return this._symbols;
3415
3454
  };
3416
- _proto6.isTimeBased = function isTimeBased() {
3417
- return false;
3455
+ _proto.startOptional = function startOptional() {
3456
+ this._optional++;
3418
3457
  };
3419
- _proto6.isSupportedBy = function isSupportedBy(temporal) {
3420
- return temporal.isSupported(ChronoField.EPOCH_DAY);
3458
+ _proto.endOptional = function endOptional() {
3459
+ this._optional--;
3421
3460
  };
3422
- _proto6.addTo = function addTo(temporal, periodToAdd) {
3423
- switch (this) {
3424
- case WEEK_BASED_YEARS:
3425
- {
3426
- var added = MathUtil.safeAdd(temporal.get(WEEK_BASED_YEAR), periodToAdd);
3427
- return temporal.with(WEEK_BASED_YEAR, added);
3428
- }
3429
- case QUARTER_YEARS:
3430
- return temporal.plus(MathUtil.intDiv(periodToAdd, 256), ChronoUnit.YEARS).plus(MathUtil.intMod(periodToAdd, 256) * 3, ChronoUnit.MONTHS);
3431
- default:
3432
- throw new IllegalStateException('Unreachable');
3461
+ _proto.getValueQuery = function getValueQuery(query) {
3462
+ var result = this._temporal.query(query);
3463
+ if (result == null && this._optional === 0) {
3464
+ throw new DateTimeException("Unable to extract value: " + this._temporal);
3433
3465
  }
3466
+ return result;
3434
3467
  };
3435
- _proto6.between = function between(temporal1, temporal2) {
3436
- switch (this) {
3437
- case WEEK_BASED_YEARS:
3438
- return MathUtil.safeSubtract(temporal2.getLong(WEEK_BASED_YEAR), temporal1.getLong(WEEK_BASED_YEAR));
3439
- case QUARTER_YEARS:
3440
- return MathUtil.intDiv(temporal1.until(temporal2, ChronoUnit.MONTHS), 3);
3441
- default:
3442
- throw new IllegalStateException('Unreachable');
3468
+ _proto.getValue = function getValue(field) {
3469
+ try {
3470
+ return this._temporal.getLong(field);
3471
+ } catch (ex) {
3472
+ if (ex instanceof DateTimeException && this._optional > 0) {
3473
+ return null;
3474
+ }
3475
+ throw ex;
3443
3476
  }
3444
3477
  };
3445
- _proto6.toString = function toString() {
3446
- return this._name;
3478
+ _proto.temporal = function temporal() {
3479
+ return this._temporal;
3447
3480
  };
3448
- return Unit;
3449
- }(TemporalUnit);
3450
- var DAY_OF_QUARTER = null;
3451
- var QUARTER_OF_YEAR = null;
3452
- var WEEK_OF_WEEK_BASED_YEAR = null;
3453
- var WEEK_BASED_YEAR = null;
3454
- var WEEK_BASED_YEARS = null;
3455
- var QUARTER_YEARS = null;
3456
- function _init$f() {
3457
- DAY_OF_QUARTER = new DAY_OF_QUARTER_FIELD();
3458
- QUARTER_OF_YEAR = new QUARTER_OF_YEAR_FIELD();
3459
- WEEK_OF_WEEK_BASED_YEAR = new WEEK_OF_WEEK_BASED_YEAR_FIELD();
3460
- WEEK_BASED_YEAR = new WEEK_BASED_YEAR_FIELD();
3461
- WEEK_BASED_YEARS = new Unit('WeekBasedYears', Duration.ofSeconds(31556952));
3462
- QUARTER_YEARS = new Unit('QuarterYears', Duration.ofSeconds(31556952 / 4));
3463
- IsoFields.DAY_OF_QUARTER = DAY_OF_QUARTER;
3464
- IsoFields.QUARTER_OF_YEAR = QUARTER_OF_YEAR;
3465
- IsoFields.WEEK_OF_WEEK_BASED_YEAR = WEEK_OF_WEEK_BASED_YEAR;
3466
- IsoFields.WEEK_BASED_YEAR = WEEK_BASED_YEAR;
3467
- IsoFields.WEEK_BASED_YEARS = WEEK_BASED_YEARS;
3468
- IsoFields.QUARTER_YEARS = QUARTER_YEARS;
3469
- LocalDate.prototype.isoWeekOfWeekyear = function () {
3470
- return this.get(IsoFields.WEEK_OF_WEEK_BASED_YEAR);
3481
+ _proto.locale = function locale() {
3482
+ return this._locale;
3471
3483
  };
3472
- LocalDate.prototype.isoWeekyear = function () {
3473
- return this.get(IsoFields.WEEK_BASED_YEAR);
3484
+ _proto.setDateTime = function setDateTime(temporal) {
3485
+ this._temporal = temporal;
3474
3486
  };
3475
- }
3487
+ _proto.setLocale = function setLocale(locale) {
3488
+ this._locale = locale;
3489
+ };
3490
+ return DateTimePrintContext;
3491
+ }();
3476
3492
 
3477
3493
  /**
3478
3494
  * @copyright (c) 2016, Philipp Thürwächter & Pattrick Hüper
@@ -4458,6 +4474,45 @@ var ZoneIdPrinterParser = function () {
4458
4474
  if (position === length) {
4459
4475
  return ~position;
4460
4476
  }
4477
+ var region = this._parseRegion(text, position);
4478
+ var fixedEndPos = this._parseFixedId(context, text, position);
4479
+ var fixedLength = fixedEndPos >= 0 ? fixedEndPos - position : 0;
4480
+ if (region != null && region.parseLength > fixedLength) {
4481
+ context.setParsedZone(ZoneRegion.ofId(region.parsedZoneId));
4482
+ return position + region.parseLength;
4483
+ }
4484
+ return fixedEndPos;
4485
+ };
4486
+ _proto._parseRegion = function _parseRegion(text, position) {
4487
+ var availableZoneIds = ZoneRulesProvider.getAvailableZoneIds();
4488
+ if (availableZoneIds.length === 0) {
4489
+ return null;
4490
+ }
4491
+ if (zoneIdTree.size !== availableZoneIds.length) {
4492
+ zoneIdTree = ZoneIdTree.createTreeMap(availableZoneIds);
4493
+ }
4494
+ var maxParseLength = text.length - position;
4495
+ var treeMap = zoneIdTree.treeMap;
4496
+ var parsedZoneId = null;
4497
+ var parseLength = 0;
4498
+ while (treeMap != null) {
4499
+ var parsedSubZoneId = text.substr(position, Math.min(treeMap.length, maxParseLength));
4500
+ treeMap = treeMap.get(parsedSubZoneId);
4501
+ if (treeMap != null && treeMap.isLeaf) {
4502
+ parsedZoneId = parsedSubZoneId;
4503
+ parseLength = treeMap.length;
4504
+ }
4505
+ }
4506
+ if (parsedZoneId == null) {
4507
+ return null;
4508
+ }
4509
+ return {
4510
+ parsedZoneId: parsedZoneId,
4511
+ parseLength: parseLength
4512
+ };
4513
+ };
4514
+ _proto._parseFixedId = function _parseFixedId(context, text, position) {
4515
+ var length = text.length;
4461
4516
  var nextChar = text.charAt(position);
4462
4517
  if (nextChar === '+' || nextChar === '-') {
4463
4518
  var newContext = context.copy();
@@ -4466,8 +4521,7 @@ var ZoneIdPrinterParser = function () {
4466
4521
  return endPos;
4467
4522
  }
4468
4523
  var offset = newContext.getParsed(ChronoField.OFFSET_SECONDS);
4469
- var zone = ZoneOffset.ofTotalSeconds(offset);
4470
- context.setParsedZone(zone);
4524
+ context.setParsedZone(ZoneOffset.ofTotalSeconds(offset));
4471
4525
  return endPos;
4472
4526
  } else if (length >= position + 2) {
4473
4527
  var nextNextChar = text.charAt(position + 1);
@@ -4488,26 +4542,6 @@ var ZoneIdPrinterParser = function () {
4488
4542
  context.setParsedZone(ZoneOffset.UTC);
4489
4543
  return position + 1;
4490
4544
  }
4491
- var availableZoneIds = ZoneRulesProvider.getAvailableZoneIds();
4492
- if (zoneIdTree.size !== availableZoneIds.length) {
4493
- zoneIdTree = ZoneIdTree.createTreeMap(availableZoneIds);
4494
- }
4495
- var maxParseLength = length - position;
4496
- var treeMap = zoneIdTree.treeMap;
4497
- var parsedZoneId = null;
4498
- var parseLength = 0;
4499
- while (treeMap != null) {
4500
- var parsedSubZoneId = text.substr(position, Math.min(treeMap.length, maxParseLength));
4501
- treeMap = treeMap.get(parsedSubZoneId);
4502
- if (treeMap != null && treeMap.isLeaf) {
4503
- parsedZoneId = parsedSubZoneId;
4504
- parseLength = treeMap.length;
4505
- }
4506
- }
4507
- if (parsedZoneId != null) {
4508
- context.setParsedZone(ZoneRegion.ofId(parsedZoneId));
4509
- return position + parseLength;
4510
- }
4511
4545
  return ~position;
4512
4546
  };
4513
4547
  _proto._parsePrefixedOffset = function _parsePrefixedOffset(context, text, prefixPos, position) {
@@ -5231,7 +5265,7 @@ var InstantPrinterParser = function () {
5231
5265
  var newContext = context.copy();
5232
5266
  var minDigits = this.fractionalDigits < 0 ? 0 : this.fractionalDigits;
5233
5267
  var maxDigits = this.fractionalDigits < 0 ? 9 : this.fractionalDigits;
5234
- var parser = new DateTimeFormatterBuilder().append(DateTimeFormatter.ISO_LOCAL_DATE).appendLiteral('T').appendValue(ChronoField.HOUR_OF_DAY, 2).appendLiteral(':').appendValue(ChronoField.MINUTE_OF_HOUR, 2).appendLiteral(':').appendValue(ChronoField.SECOND_OF_MINUTE, 2).appendFraction(ChronoField.NANO_OF_SECOND, minDigits, maxDigits, true).appendLiteral('Z').toFormatter()._toPrinterParser(false);
5268
+ var parser = new DateTimeFormatterBuilder().append(DateTimeFormatter.ISO_LOCAL_DATE).appendLiteral('T').appendValue(ChronoField.HOUR_OF_DAY, 2).appendLiteral(':').appendValue(ChronoField.MINUTE_OF_HOUR, 2).appendLiteral(':').appendValue(ChronoField.SECOND_OF_MINUTE, 2).appendFraction(ChronoField.NANO_OF_SECOND, minDigits, maxDigits, true).appendOffsetId().toFormatter()._toPrinterParser(false);
5235
5269
  var pos = parser.parse(newContext, text, position);
5236
5270
  if (pos < 0) {
5237
5271
  return pos;
@@ -5243,6 +5277,8 @@ var InstantPrinterParser = function () {
5243
5277
  var min = newContext.getParsed(ChronoField.MINUTE_OF_HOUR);
5244
5278
  var secVal = newContext.getParsed(ChronoField.SECOND_OF_MINUTE);
5245
5279
  var nanoVal = newContext.getParsed(ChronoField.NANO_OF_SECOND);
5280
+ var offsetSecs = newContext.getParsed(ChronoField.OFFSET_SECONDS);
5281
+ var offset = offsetSecs != null ? offsetSecs : 0;
5246
5282
  var sec = secVal != null ? secVal : 0;
5247
5283
  var nano = nanoVal != null ? nanoVal : 0;
5248
5284
  var year = MathUtil.intMod(yearParsed, 10000);
@@ -5257,7 +5293,7 @@ var InstantPrinterParser = function () {
5257
5293
  var instantSecs;
5258
5294
  try {
5259
5295
  var ldt = LocalDateTime.of(year, month, day, hour, min, sec, 0).plusDays(days);
5260
- instantSecs = ldt.toEpochSecond(ZoneOffset.UTC);
5296
+ instantSecs = ldt.toEpochSecond(ZoneOffset.ofTotalSeconds(offset));
5261
5297
  instantSecs += MathUtil.safeMultiply(MathUtil.intDiv(yearParsed, 10000), SECONDS_PER_10000_YEARS);
5262
5298
  } catch (ex) {
5263
5299
  return ~position;
@@ -5504,7 +5540,7 @@ function _init$d() {
5504
5540
  DateTimeFormatter.ISO_OFFSET_DATE = new DateTimeFormatterBuilder().parseCaseInsensitive().append(DateTimeFormatter.ISO_LOCAL_DATE).appendOffsetId().toFormatter(ResolverStyle.STRICT).withChronology(IsoChronology.INSTANCE);
5505
5541
  DateTimeFormatter.ISO_OFFSET_TIME = new DateTimeFormatterBuilder().parseCaseInsensitive().append(DateTimeFormatter.ISO_LOCAL_TIME).appendOffsetId().toFormatter(ResolverStyle.STRICT).withChronology(IsoChronology.INSTANCE);
5506
5542
  DateTimeFormatter.ISO_ORDINAL_DATE = new DateTimeFormatterBuilder().appendValue(ChronoField.YEAR, 4, 10, SignStyle.EXCEEDS_PAD).appendLiteral('-').appendValue(ChronoField.DAY_OF_YEAR).toFormatter(ResolverStyle.STRICT);
5507
- DateTimeFormatter.ISO_WEEK_DATE = new DateTimeFormatterBuilder().appendValue(ChronoField.YEAR, 4, 10, SignStyle.EXCEEDS_PAD).appendLiteral('-W').appendValue(ChronoField.ALIGNED_WEEK_OF_YEAR).appendLiteral('-').appendValue(ChronoField.DAY_OF_WEEK).toFormatter(ResolverStyle.STRICT);
5543
+ DateTimeFormatter.ISO_WEEK_DATE = new DateTimeFormatterBuilder().parseCaseInsensitive().appendValue(IsoFields.WEEK_BASED_YEAR, 4, 10, SignStyle.EXCEEDS_PAD).appendLiteral('-W').appendValue(IsoFields.WEEK_OF_WEEK_BASED_YEAR, 2).appendLiteral('-').appendValue(ChronoField.DAY_OF_WEEK, 1).toFormatter(ResolverStyle.STRICT).withChronology(IsoChronology.INSTANCE);
5508
5544
  DateTimeFormatter.ISO_DATE = new DateTimeFormatterBuilder().parseCaseInsensitive().append(DateTimeFormatter.ISO_LOCAL_DATE).optionalStart().appendOffsetId().optionalEnd().toFormatter(ResolverStyle.STRICT).withChronology(IsoChronology.INSTANCE);
5509
5545
  DateTimeFormatter.ISO_TIME = new DateTimeFormatterBuilder().parseCaseInsensitive().append(DateTimeFormatter.ISO_LOCAL_TIME).optionalStart().appendOffsetId().optionalEnd().toFormatter(ResolverStyle.STRICT);
5510
5546
  DateTimeFormatter.ISO_DATE_TIME = new DateTimeFormatterBuilder().append(DateTimeFormatter.ISO_LOCAL_DATE_TIME).optionalStart().appendOffsetId().optionalEnd().toFormatter(ResolverStyle.STRICT).withChronology(IsoChronology.INSTANCE);
@@ -9679,7 +9715,7 @@ var Instant = function (_Temporal) {
9679
9715
  throw new DateTimeException('Unit must divide into a standard day without remainder');
9680
9716
  }
9681
9717
  var nod = MathUtil.intMod(this._seconds, LocalTime.SECONDS_PER_DAY) * LocalTime.NANOS_PER_SECOND + this._nanos;
9682
- var result = MathUtil.intDiv(nod, dur) * dur;
9718
+ var result = MathUtil.floorDiv(nod, dur) * dur;
9683
9719
  return this.plusNanos(result - nod);
9684
9720
  };
9685
9721
  _proto._plusUnit = function _plusUnit(amountToAdd, unit) {
@@ -9788,8 +9824,16 @@ var Instant = function (_Temporal) {
9788
9824
  };
9789
9825
  _proto._microsUntil = function _microsUntil(end) {
9790
9826
  var secsDiff = MathUtil.safeSubtract(end.epochSecond(), this.epochSecond());
9827
+ var nanosDiff = end.nano() - this.nano();
9828
+ if (secsDiff > 0 && nanosDiff < 0) {
9829
+ secsDiff--;
9830
+ nanosDiff += LocalTime.NANOS_PER_SECOND;
9831
+ } else if (secsDiff < 0 && nanosDiff > 0) {
9832
+ secsDiff++;
9833
+ nanosDiff -= LocalTime.NANOS_PER_SECOND;
9834
+ }
9791
9835
  var totalMicros = MathUtil.safeMultiply(secsDiff, 1000000);
9792
- return MathUtil.safeAdd(totalMicros, MathUtil.intDiv(end.nano() - this.nano(), 1000));
9836
+ return MathUtil.safeAdd(totalMicros, MathUtil.intDiv(nanosDiff, 1000));
9793
9837
  };
9794
9838
  _proto._nanosUntil = function _nanosUntil(end) {
9795
9839
  var secsDiff = MathUtil.safeSubtract(end.epochSecond(), this.epochSecond());
@@ -10328,7 +10372,7 @@ function init() {
10328
10372
  _init$l();
10329
10373
  _init$k();
10330
10374
  _init$3();
10331
- _init$f();
10375
+ _init$g();
10332
10376
  _init$1();
10333
10377
  _init$j();
10334
10378
  _init$2();
@@ -10339,7 +10383,7 @@ function init() {
10339
10383
  _init$b();
10340
10384
  _init$c();
10341
10385
  _init$h();
10342
- _init$g();
10386
+ _init$f();
10343
10387
  _init$7();
10344
10388
  _init();
10345
10389
  _init$9();