How to use the @js-joda/core.ChronoField.DAY_OF_WEEK function in @js-joda/core

To help you get started, we’ve selected a few @js-joda/core examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github js-joda / js-joda / packages / locale / src / temporal / WeekFields.js View on Github external
_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));
        }
github js-joda / js-joda / packages / locale / src / temporal / WeekFields.js View on Github external
const localDow = this._range.checkValidIntValue(value, this);
            const isoDow = MathUtil.floorMod((sow - 1) + (localDow - 1), 7) + 1;
            fieldValues.put(ChronoField.DAY_OF_WEEK, isoDow);
            return null;
        }
        if (fieldValues.containsKey(ChronoField.DAY_OF_WEEK) === false) {
            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);
github js-joda / js-joda / packages / locale / src / temporal / WeekFields.js View on Github external
_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;
    }
github js-joda / js-joda / packages / locale / src / format / cldr / CldrDateTimeTextProvider.js View on Github external
data[1] = monthsData.abbreviated[1];
            data[2] = monthsData.abbreviated[2];
            data[3] = monthsData.abbreviated[3];
            data[4] = monthsData.abbreviated[4];
            data[5] = monthsData.abbreviated[5];
            data[6] = monthsData.abbreviated[6];
            data[7] = monthsData.abbreviated[7];
            data[8] = monthsData.abbreviated[8];
            data[9] = monthsData.abbreviated[9];
            data[10] = monthsData.abbreviated[10];
            data[11] = monthsData.abbreviated[11];
            data[12] = monthsData.abbreviated[12];
            styleMap[TextStyle.SHORT] = data;
            return this._createLocaleStore(styleMap);
        }
        if (field === ChronoField.DAY_OF_WEEK) {
            const daysData = cldr.main('dates/calendars/gregorian/days/format');
            const styleMap = {};
            let data = {};
            data[1] = daysData.wide.mon;
            data[2] = daysData.wide.tue;
            data[3] = daysData.wide.wed;
            data[4] = daysData.wide.thu;
            data[5] = daysData.wide.fri;
            data[6] = daysData.wide.sat;
            data[7] = daysData.wide.sun;
            styleMap[TextStyle.FULL] = data;

            data = {};
            data[1] = daysData.narrow.mon;
            data[2] = daysData.narrow.tue;
            data[3] = daysData.narrow.wed;