Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
days = weeks * 7 + (dow - dateDow);
}
date = date.plus(days, ChronoUnit.DAYS);
if (resolverStyle === ResolverStyle.STRICT) {
if (date.getLong(ChronoField.MONTH_OF_YEAR) !== fieldValues.get(ChronoField.MONTH_OF_YEAR)) {
throw new DateTimeException('Strict mode rejected date parsed to a different month');
}
}
fieldValues.remove(this);
fieldValues.remove(ChronoField.YEAR);
fieldValues.remove(ChronoField.MONTH_OF_YEAR);
fieldValues.remove(ChronoField.DAY_OF_WEEK);
return date;
} else if (this._rangeUnit === ChronoUnit.YEARS) { // week-of-year
const value = fieldValues.remove(this);
let date = LocalDate.of(year, 1, 1); // TODO: chrono.date(year, 1, 1);
let days;
if (resolverStyle === ResolverStyle.LENIENT) {
const dateDow = this._localizedDayOfWeek(date, sow);
const weeks = value - this._localizedWeekOfYear(date, dateDow);
days = weeks * 7 + (dow - dateDow);
} else {
const dateDow = this._localizedDayOfWeek(date, sow);
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');
}
if (fieldValues.containsKey(ChronoField.MONTH_OF_YEAR) === false) {
return null;
}
const value = fieldValues.remove(this);
let date;
let days;
if (resolverStyle === ResolverStyle.LENIENT) {
const month = fieldValues.get(ChronoField.MONTH_OF_YEAR);
date = LocalDate.of(year, 1, 1); // TODO: chrono.date(year, 1, 1);
date = date.plus(month - 1, ChronoUnit.MONTHS);
const dateDow = this._localizedDayOfWeek(date, sow);
const weeks = value - this._localizedWeekOfMonth(date, dateDow);
days = weeks * 7 + (dow - dateDow);
} else {
const month = ChronoField.MONTH_OF_YEAR.checkValidIntValue(fieldValues.get(ChronoField.MONTH_OF_YEAR));
date = LocalDate.of(year, month, 8); // TODO: chrono.date(year, month, 8);
const dateDow = this._localizedDayOfWeek(date, sow);
const wom = this._range.checkValidIntValue(value, this);
const weeks = wom - this._localizedWeekOfMonth(date, dateDow);
days = weeks * 7 + (dow - dateDow);
}
date = date.plus(days, ChronoUnit.DAYS);
if (resolverStyle === ResolverStyle.STRICT) {
if (date.getLong(ChronoField.MONTH_OF_YEAR) !== fieldValues.get(ChronoField.MONTH_OF_YEAR)) {
throw new DateTimeException('Strict mode rejected date parsed to a different month');
}
}
fieldValues.remove(this);
fieldValues.remove(ChronoField.YEAR);
fieldValues.remove(ChronoField.MONTH_OF_YEAR);
fieldValues.remove(ChronoField.DAY_OF_WEEK);
return date;
return null;
}
// week-based-year
if (this._rangeUnit === ChronoUnit.FOREVER) {
if (fieldValues.containsKey(this._weekDef.weekOfWeekBasedYear()) === false) {
return null;
}
// const chrono = IsoChronology.INSTANCE; //TODO: Chronology.from(partialTemporal); // defaults to ISO
const isoDow = ChronoField.DAY_OF_WEEK.checkValidIntValue(fieldValues.get(ChronoField.DAY_OF_WEEK));
const dow = MathUtil.floorMod(isoDow - sow, 7) + 1;
const wby = this.range().checkValidIntValue(fieldValues.get(this), this);
let date;
let days;
if (resolverStyle === ResolverStyle.LENIENT) {
date = LocalDate.of(wby, 1, this._weekDef.minimalDaysInFirstWeek()); //TODO: chrono.date(wby, 1, this._weekDef.minimalDaysInFirstWeek());
const wowby = fieldValues.get(this._weekDef.weekOfWeekBasedYear());
const dateDow = this._localizedDayOfWeek(date, sow);
const weeks = wowby - this._localizedWeekOfYear(date, dateDow);
days = weeks * 7 + (dow - dateDow);
} else {
date = LocalDate.of(wby, 1, this._weekDef.minimalDaysInFirstWeek()); //TODO: chrono.date(wby, 1, this._weekDef.minimalDaysInFirstWeek());
const wowby = this._weekDef.weekOfWeekBasedYear().range().checkValidIntValue(
fieldValues.get(this._weekDef.weekOfWeekBasedYear()), this._weekDef.weekOfWeekBasedYear);
const dateDow = this._localizedDayOfWeek(date, sow);
const weeks = wowby - this._localizedWeekOfYear(date, dateDow);
days = weeks * 7 + (dow - dateDow);
}
date = date.plus(days, ChronoUnit.DAYS);
if (resolverStyle === ResolverStyle.STRICT) {
if (date.getLong(this) !== fieldValues.get(this)) {
throw new DateTimeException('Strict mode rejected date parsed to a different year');
return null;
}
const isoDow = ChronoField.DAY_OF_WEEK.checkValidIntValue(fieldValues.get(ChronoField.DAY_OF_WEEK));
const dow = MathUtil.floorMod(isoDow - sow, 7) + 1;
const year = ChronoField.YEAR.checkValidIntValue(fieldValues.get(ChronoField.YEAR));
// const chrono = IsoChronology.INSTANCE; //TODO: Chronology.from(partialTemporal); // defaults to ISO
if (this._rangeUnit === ChronoUnit.MONTHS) { // week-of-month
if (fieldValues.containsKey(ChronoField.MONTH_OF_YEAR) === false) {
return null;
}
const value = fieldValues.remove(this);
let date;
let days;
if (resolverStyle === ResolverStyle.LENIENT) {
const month = fieldValues.get(ChronoField.MONTH_OF_YEAR);
date = LocalDate.of(year, 1, 1); // TODO: chrono.date(year, 1, 1);
date = date.plus(month - 1, ChronoUnit.MONTHS);
const dateDow = this._localizedDayOfWeek(date, sow);
const weeks = value - this._localizedWeekOfMonth(date, dateDow);
days = weeks * 7 + (dow - dateDow);
} else {
const month = ChronoField.MONTH_OF_YEAR.checkValidIntValue(fieldValues.get(ChronoField.MONTH_OF_YEAR));
date = LocalDate.of(year, month, 8); // TODO: chrono.date(year, month, 8);
const dateDow = this._localizedDayOfWeek(date, sow);
const wom = this._range.checkValidIntValue(value, this);
const weeks = wom - this._localizedWeekOfMonth(date, dateDow);
days = weeks * 7 + (dow - dateDow);
}
date = date.plus(days, ChronoUnit.DAYS);
if (resolverStyle === ResolverStyle.STRICT) {
if (date.getLong(ChronoField.MONTH_OF_YEAR) !== fieldValues.get(ChronoField.MONTH_OF_YEAR)) {
throw new DateTimeException('Strict mode rejected date parsed to a different month');