Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
} 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._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);
}
IsoFields,
LocalDate,
ResolverStyle,
ValueRange,
Year
} from '@js-joda/core';
import cldrData from 'cldr-data';
import Cldr from 'cldrjs';
const { MathUtil, assert: { requireNonNull, requireInstance } } = jodaInternal;
//-----------------------------------------------------------------------
const DAY_OF_WEEK_RANGE = ValueRange.of(1, 7);
const WEEK_OF_MONTH_RANGE = ValueRange.of(0, 1, 4, 6);
const WEEK_OF_YEAR_RANGE = ValueRange.of(0, 1, 52, 54);
const WEEK_OF_WEEK_BASED_YEAR_RANGE = ValueRange.of(1, 52, 53);
const WEEK_BASED_YEAR_RANGE = ChronoField.YEAR.range();
/* map from the string from cldr `firstDay()` to DayOfWeek */
const _weekDayMap = {
'mon': DayOfWeek.MONDAY,
'tue': DayOfWeek.TUESDAY,
'wed': DayOfWeek.WEDNESDAY,
'thu': DayOfWeek.THURSDAY,
'fri': DayOfWeek.FRIDAY,
'sat': DayOfWeek.SATURDAY,
'sun': DayOfWeek.SUNDAY,
};
/**
* Field type that computes DayOfWeek, WeekOfMonth, and WeekOfYear
* based on a WeekFields.
IllegalStateException,
IsoChronology,
IsoFields,
LocalDate,
ResolverStyle,
ValueRange,
Year
} from '@js-joda/core';
import cldrData from 'cldr-data';
import Cldr from 'cldrjs';
const { MathUtil, assert: { requireNonNull, requireInstance } } = jodaInternal;
//-----------------------------------------------------------------------
const DAY_OF_WEEK_RANGE = ValueRange.of(1, 7);
const WEEK_OF_MONTH_RANGE = ValueRange.of(0, 1, 4, 6);
const WEEK_OF_YEAR_RANGE = ValueRange.of(0, 1, 52, 54);
const WEEK_OF_WEEK_BASED_YEAR_RANGE = ValueRange.of(1, 52, 53);
const WEEK_BASED_YEAR_RANGE = ChronoField.YEAR.range();
/* map from the string from cldr `firstDay()` to DayOfWeek */
const _weekDayMap = {
'mon': DayOfWeek.MONDAY,
'tue': DayOfWeek.TUESDAY,
'wed': DayOfWeek.WEDNESDAY,
'thu': DayOfWeek.THURSDAY,
'fri': DayOfWeek.FRIDAY,
'sat': DayOfWeek.SATURDAY,
'sun': DayOfWeek.SUNDAY,
};
/**
IsoChronology,
IsoFields,
LocalDate,
ResolverStyle,
ValueRange,
Year
} from '@js-joda/core';
import cldrData from 'cldr-data';
import Cldr from 'cldrjs';
const { MathUtil, assert: { requireNonNull, requireInstance } } = jodaInternal;
//-----------------------------------------------------------------------
const DAY_OF_WEEK_RANGE = ValueRange.of(1, 7);
const WEEK_OF_MONTH_RANGE = ValueRange.of(0, 1, 4, 6);
const WEEK_OF_YEAR_RANGE = ValueRange.of(0, 1, 52, 54);
const WEEK_OF_WEEK_BASED_YEAR_RANGE = ValueRange.of(1, 52, 53);
const WEEK_BASED_YEAR_RANGE = ChronoField.YEAR.range();
/* map from the string from cldr `firstDay()` to DayOfWeek */
const _weekDayMap = {
'mon': DayOfWeek.MONDAY,
'tue': DayOfWeek.TUESDAY,
'wed': DayOfWeek.WEDNESDAY,
'thu': DayOfWeek.THURSDAY,
'fri': DayOfWeek.FRIDAY,
'sat': DayOfWeek.SATURDAY,
'sun': DayOfWeek.SUNDAY,
};
/**
* Field type that computes DayOfWeek, WeekOfMonth, and WeekOfYear
IllegalArgumentException,
IllegalStateException,
IsoChronology,
IsoFields,
LocalDate,
ResolverStyle,
ValueRange,
Year
} from '@js-joda/core';
import cldrData from 'cldr-data';
import Cldr from 'cldrjs';
const { MathUtil, assert: { requireNonNull, requireInstance } } = jodaInternal;
//-----------------------------------------------------------------------
const DAY_OF_WEEK_RANGE = ValueRange.of(1, 7);
const WEEK_OF_MONTH_RANGE = ValueRange.of(0, 1, 4, 6);
const WEEK_OF_YEAR_RANGE = ValueRange.of(0, 1, 52, 54);
const WEEK_OF_WEEK_BASED_YEAR_RANGE = ValueRange.of(1, 52, 53);
const WEEK_BASED_YEAR_RANGE = ChronoField.YEAR.range();
/* map from the string from cldr `firstDay()` to DayOfWeek */
const _weekDayMap = {
'mon': DayOfWeek.MONDAY,
'tue': DayOfWeek.TUESDAY,
'wed': DayOfWeek.WEDNESDAY,
'thu': DayOfWeek.THURSDAY,
'fri': DayOfWeek.FRIDAY,
'sat': DayOfWeek.SATURDAY,
'sun': DayOfWeek.SUNDAY,
};