Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
_rangeWOWBY(temporal) {
const sow = this._weekDef.firstDayOfWeek().value();
const isoDow = temporal.get(ChronoField.DAY_OF_WEEK);
const dow = MathUtil.floorMod(isoDow - sow, 7) + 1;
const woy = this._localizedWeekOfYear(temporal, dow);
if (woy === 0) {
// TODO: we use IsoChronology for now
return this._rangeWOWBY(IsoChronology.INSTANCE.date(temporal).minus(2, ChronoUnit.WEEKS));
// return this._rangeWOWBY(Chronology.from(temporal).date(temporal).minus(2, ChronoUnit.WEEKS));
}
const offset = this._startOfWeekOffset(temporal.get(ChronoField.DAY_OF_YEAR), dow);
const year = temporal.get(ChronoField.YEAR);
const yearLen = Year.isLeap(year) ? 366 : 365;
const weekIndexOfFirstWeekNextYear = ComputedDayOfField._computeWeek(offset, yearLen + this._weekDef.minimalDaysInFirstWeek());
if (woy >= weekIndexOfFirstWeekNextYear) {
// TODO: we use IsoChronology for now
return this._rangeWOWBY(IsoChronology.INSTANCE.date(temporal).plus(2, ChronoUnit.WEEKS));
// return this._rangeWOWBY(Chronology.from(temporal).date(temporal).plus(2, ChronoUnit.WEEKS));
}
return ValueRange.of(1, weekIndexOfFirstWeekNextYear - 1);
}
_localizedWBY(temporal) {
const sow = this._weekDef.firstDayOfWeek().value();
const isoDow = temporal.get(ChronoField.DAY_OF_WEEK);
const dow = MathUtil.floorMod(isoDow - sow, 7) + 1;
const year = temporal.get(ChronoField.YEAR);
const woy = this._localizedWeekOfYear(temporal, dow);
if (woy === 0) {
return year - 1;
} else if (woy < 53) {
return year;
}
const offset = this._startOfWeekOffset(temporal.get(ChronoField.DAY_OF_YEAR), dow);
const yearLen = Year.isLeap(year) ? 366 : 365;
const weekIndexOfFirstWeekNextYear = ComputedDayOfField._computeWeek(offset, yearLen + this._weekDef.minimalDaysInFirstWeek());
if (woy >= weekIndexOfFirstWeekNextYear) {
return year + 1;
}
return year;
}
_localizedWOWBY(temporal) {
const sow = this._weekDef.firstDayOfWeek().value();
const isoDow = temporal.get(ChronoField.DAY_OF_WEEK);
const dow = MathUtil.floorMod(isoDow - sow, 7) + 1;
const woy = this._localizedWeekOfYear(temporal, dow);
if (woy === 0) {
const previous = LocalDate.from(temporal).minus(1, ChronoUnit.WEEKS);
return this._localizedWeekOfYear(previous, dow) + 1;
} else if (woy >= 53) {
const offset = this._startOfWeekOffset(temporal.get(ChronoField.DAY_OF_YEAR), dow);
const year = temporal.get(ChronoField.YEAR);
const yearLen = Year.isLeap(year) ? 366 : 365;
const weekIndexOfFirstWeekNextYear = ComputedDayOfField._computeWeek(offset, yearLen + this._weekDef.minimalDaysInFirstWeek());
if (woy >= weekIndexOfFirstWeekNextYear) {
return (woy - (weekIndexOfFirstWeekNextYear - 1));
}
}
return woy;
}