Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
// Offset the ISO DOW by the start of this week
const sow = this._weekDef.firstDayOfWeek().value();
const dow = this._localizedDayOfWeek(temporal, sow);
if (this._rangeUnit === ChronoUnit.WEEKS) {
return dow;
} else if (this._rangeUnit === ChronoUnit.MONTHS) {
return this._localizedWeekOfMonth(temporal, dow);
} else if (this._rangeUnit === ChronoUnit.YEARS) {
return this._localizedWeekOfYear(temporal, dow);
} else if (this._rangeUnit === IsoFields.WEEK_BASED_YEARS) {
return this._localizedWOWBY(temporal);
} else if (this._rangeUnit === ChronoUnit.FOREVER) {
return this._localizedWBY(temporal);
} else {
throw new IllegalStateException('unreachable');
}
}
rangeRefinedBy(temporal) {
if (this._rangeUnit === ChronoUnit.WEEKS) {
return this._range;
}
let field = null;
if (this._rangeUnit === ChronoUnit.MONTHS) {
field = ChronoField.DAY_OF_MONTH;
} else if (this._rangeUnit === ChronoUnit.YEARS) {
field = ChronoField.DAY_OF_YEAR;
} else if (this._rangeUnit === IsoFields.WEEK_BASED_YEARS) {
return this._rangeWOWBY(temporal);
} else if (this._rangeUnit === ChronoUnit.FOREVER) {
return temporal.range(ChronoField.YEAR);
} else {
throw new IllegalStateException('unreachable');
}
// Offset the ISO DOW by the start of this week
const sow = this._weekDef.firstDayOfWeek().value();
const isoDow = temporal.get(ChronoField.DAY_OF_WEEK);
const dow = MathUtil.floorMod(isoDow - sow, 7) + 1;
const offset = this._startOfWeekOffset(temporal.get(field), dow);
const fieldRange = temporal.range(field);
return ValueRange.of(ComputedDayOfField._computeWeek(offset, fieldRange.minimum()),
ComputedDayOfField._computeWeek(offset, fieldRange.maximum()));
}
const woy = this._range.checkValidIntValue(value, this);
const weeks = woy - this._localizedWeekOfYear(date, dateDow);
days = weeks * 7 + (dow - dateDow);
}
date = date.plus(days, ChronoUnit.DAYS);
if (resolverStyle === ResolverStyle.STRICT) {
if (date.getLong(ChronoField.YEAR) !== fieldValues.get(ChronoField.YEAR)) {
throw new DateTimeException('Strict mode rejected date parsed to a different year');
}
}
fieldValues.remove(this);
fieldValues.remove(ChronoField.YEAR);
fieldValues.remove(ChronoField.DAY_OF_WEEK);
return date;
} else {
throw new IllegalStateException('unreachable');
}
}