How to use the @js-joda/core.ChronoUnit.DAYS 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 / examples / examples / node / node-modules-03.js View on Github external
/* eslint-disable no-console */

const {
    ChronoUnit,
    LocalDate,
    LocalDateTime,
    ZonedDateTime,
} = require('@js-joda/core');

console.log(LocalDateTime.now().toString());
console.log(ZonedDateTime.now().toString());
console.log(LocalDate.now().until(LocalDate.now().plusDays(10), ChronoUnit.DAYS));
console.log('node-modules-03 done');
github js-joda / js-joda / packages / examples / examples / webpack / webpack-index.js View on Github external
import {
    ChronoUnit,
    Duration,
    Instant,
    LocalDate,
    LocalDateTime,
    ZonedDateTime,
    ZoneId,
} from '@js-joda/core';
import {
    Interval,
} from '@js-joda/extra';
import '@js-joda/timezone';

console.log(LocalDate.now().until(LocalDate.now().plusDays(10), ChronoUnit.DAYS));
console.log(LocalDateTime.now().toString());
console.log(ZonedDateTime.now().toString());
console.log(ZonedDateTime.now(ZoneId.of('America/New_York')).toString());
console.log(Interval.of(Instant.now(), Duration.ofMinutes(1)).toString());
console.log('webpack-index done');
github js-joda / js-joda / packages / examples / examples / node / es6-modules-01.js View on Github external
import {
    ChronoUnit,
    Duration,
    Instant,
    LocalDate,
    LocalDateTime,
    ZonedDateTime,
    ZoneId,
} from '@js-joda/core';
import {
    Interval,
} from '@js-joda/extra';
import '@js-joda/timezone';

console.log(LocalDate.now().until(LocalDate.now().plusDays(10), ChronoUnit.DAYS));
console.log(LocalDateTime.now().toString());
console.log(ZonedDateTime.now().toString());
console.log(ZonedDateTime.now(ZoneId.of('America/New_York')).toString());
console.log(Interval.of(Instant.now(), Duration.ofMinutes(1)).toString());
console.log('es6-modules-01 done');
github js-joda / js-joda / packages / locale / src / temporal / WeekFields.js View on Github external
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');
                }
            }
            fieldValues.remove(this);
            fieldValues.remove(this._weekDef.weekOfWeekBasedYear());
            fieldValues.remove(ChronoField.DAY_OF_WEEK);
            return date;
        }

        if (fieldValues.containsKey(ChronoField.YEAR) === false) {
            return null;
        }
        const isoDow = ChronoField.DAY_OF_WEEK.checkValidIntValue(fieldValues.get(ChronoField.DAY_OF_WEEK));
        const dow = MathUtil.floorMod(isoDow - sow, 7) + 1;