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