How to use the luxon.Interval.fromDateTimes function in luxon

To help you get started, we’ve selected a few luxon 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 flow-typed / flow-typed / definitions / npm / luxon_v1.x.x / flow_v0.104.x- / test_luxon.js View on Github external
(Interval.before(DateTime.utc(), Duration.fromObject({ year: 1 })): Interval);
(Interval.before(DateTime.utc(), { year: 1 }): Interval);
(Interval.before(DateTime.utc(), 1231234): Interval);
(Interval.before(
  { year: 2017, month: 1 },
  Duration.fromObject({ year: 1 })
): Interval);
(Interval.before({ year: 2017, month: 1 }, { year: 1 }): Interval);
(Interval.before({ year: 2017, month: 1 }, 123123): Interval);
// $ExpectError
(Interval.before({ year: 2017, month: 1, foo: "bar" }, { year: 1 }): Interval);
// $ExpectError
(Interval.before({ year: 2017, month: 1 }, { year: 1, foo: "bar" }): Interval);

(Interval.fromDateTimes(DateTime.utc(), DateTime.utc()): Interval);
(Interval.fromDateTimes(DateTime.utc(), { year: 2017, month: 1 }): Interval);
(Interval.fromDateTimes({ year: 2016, month: 1 }, DateTime.utc()): Interval);
(Interval.fromDateTimes(
  { year: 2016, month: 1 },
  { year: 2017, month: 1 }
): Interval);
(Interval.fromDateTimes(
  // $ExpectError
  { year: 2016, month: 1, foo: 'bar' },
  { year: 2017, month: 1 }
): Interval);
(Interval.fromDateTimes(
  { year: 2016, month: 1 },
  // $ExpectError
  { year: 2017, month: 1, foo: 'bar' }
): Interval);
github flow-typed / flow-typed / definitions / npm / luxon_v0.4.x / flow_v0.104.x- / test_luxon.js View on Github external
(Interval.before(DateTime.utc(), { year: 1 }): Interval);
(Interval.before(DateTime.utc(), 1231234): Interval);
(Interval.before(
  { year: 2017, month: 1 },
  Duration.fromObject({ year: 1 })
): Interval);
(Interval.before({ year: 2017, month: 1 }, { year: 1 }): Interval);
(Interval.before({ year: 2017, month: 1 }, 123123): Interval);
// $ExpectError
(Interval.before({ year: 2017, month: 1, foo: "bar" }, { year: 1 }): Interval);
// $ExpectError
(Interval.before({ year: 2017, month: 1 }, { year: 1, foo: "bar" }): Interval);

(Interval.fromDateTimes(DateTime.utc(), DateTime.utc()): Interval);
(Interval.fromDateTimes(DateTime.utc(), { year: 2017, month: 1 }): Interval);
(Interval.fromDateTimes({ year: 2016, month: 1 }, DateTime.utc()): Interval);
(Interval.fromDateTimes(
  { year: 2016, month: 1 },
  { year: 2017, month: 1 }
): Interval);
(Interval.fromDateTimes(
  // $ExpectError
  { year: 2016, month: 1, foo: 'bar' },
  { year: 2017, month: 1 }
): Interval);
(Interval.fromDateTimes(
  { year: 2016, month: 1 },
  // $ExpectError
  { year: 2017, month: 1, foo: 'bar' }
): Interval);

(Interval.fromISO("23;lkj1"): Interval);
github flow-typed / flow-typed / definitions / npm / luxon_v1.x.x / flow_v0.104.x- / test_luxon.js View on Github external
(Interval.before(DateTime.utc(), Duration.fromObject({ year: 1 })): Interval);
(Interval.before(DateTime.utc(), { year: 1 }): Interval);
(Interval.before(DateTime.utc(), 1231234): Interval);
(Interval.before(
  { year: 2017, month: 1 },
  Duration.fromObject({ year: 1 })
): Interval);
(Interval.before({ year: 2017, month: 1 }, { year: 1 }): Interval);
(Interval.before({ year: 2017, month: 1 }, 123123): Interval);
// $ExpectError
(Interval.before({ year: 2017, month: 1, foo: "bar" }, { year: 1 }): Interval);
// $ExpectError
(Interval.before({ year: 2017, month: 1 }, { year: 1, foo: "bar" }): Interval);

(Interval.fromDateTimes(DateTime.utc(), DateTime.utc()): Interval);
(Interval.fromDateTimes(DateTime.utc(), { year: 2017, month: 1 }): Interval);
(Interval.fromDateTimes({ year: 2016, month: 1 }, DateTime.utc()): Interval);
(Interval.fromDateTimes(
  { year: 2016, month: 1 },
  { year: 2017, month: 1 }
): Interval);
(Interval.fromDateTimes(
  // $ExpectError
  { year: 2016, month: 1, foo: 'bar' },
  { year: 2017, month: 1 }
): Interval);
(Interval.fromDateTimes(
  { year: 2016, month: 1 },
  // $ExpectError
  { year: 2017, month: 1, foo: 'bar' }
): Interval);
github unscrollinc / unscroll / client / src / components / Timeline / Timeline.js View on Github external
if (s.invalid === null && b.invalid === null) {
                this.initialize(
                    interval,
                    this.props.searchQuery,
                    this.props.slug
                );
            }
        } else {
            // This is the default state
            const s = DateTime.fromObject({ year: 2010, month: 1 }).startOf(
                'month'
            );
            const b = DateTime.fromObject({ year: 2019, month: 12 }).endOf(
                'month'
            );
            const interval = Interval.fromDateTimes(s, b);
            this.initialize(interval, null);
        }
        return null;
    }
github unscrollinc / unscroll / client / src / components / Timeline / Timeline.js View on Github external
const rawInterval = Interval.fromDateTimes(s, b);
                        const interval = moreThanOne
                            ? rawInterval.divideEqually(5)[3]
                            : rawInterval;
                        _this.initialize(
                            interval,
                            this.props.searchQuery,
                            this.props.slug
                        );
                    }
                });
        } else if (this.props.hasInterval) {
            const s = DateTime.fromISO(this.props.start);
            const b = DateTime.fromISO(this.props.before);
            const interval = Interval.fromDateTimes(s, b);
            if (s.invalid === null && b.invalid === null) {
                this.initialize(
                    interval,
                    this.props.searchQuery,
                    this.props.slug
                );
            }
        } else {
            // This is the default state
            const s = DateTime.fromObject({ year: 2010, month: 1 }).startOf(
                'month'
            );
            const b = DateTime.fromObject({ year: 2019, month: 12 }).endOf(
                'month'
            );
            const interval = Interval.fromDateTimes(s, b);
github you-dont-need / You-Dont-Need-Momentjs / __tests__ / index.js View on Github external
it('Is Between', () => {
    const m = moment('2010-10-20').isBetween('2010-10-19', '2010-10-25');
    const d = date.isWithinInterval(new Date(2010, 9, 20), {
      start: new Date(2010, 9, 19),
      end: new Date(2010, 9, 25),
    });
    const day = dayjs('2010-10-20').isBetween('2010-10-19', '2010-10-25'); //plugin
    const luxon = Interval.fromDateTimes(
      DateTime.fromISO('2010-10-19'),
      DateTime.fromISO('2010-10-25')
    ).contains(DateTime.fromISO('2010-10-20'));

    expect(m).toBeTruthy();
    expect(d).toBeTruthy();
    expect(day).toBeTruthy();
    expect(luxon).toBeTruthy();
  });
github microsoft / pai / src / webportal / src / app / job / job-view / fabric / job-retry / job-retry-card.jsx View on Github external
function getAttemptDurationString(attempt) {
  const start =
    attempt.attemptStartedTime &&
    DateTime.fromMillis(attempt.attemptStartedTime);
  const end = attempt.attemptCompletedTime
    ? DateTime.fromMillis(attempt.attemptCompletedTime)
    : DateTime.utc();
  if (start && end) {
    return getDurationString(
      Interval.fromDateTimes(start, end || DateTime.utc()).toDuration([
        'days',
        'hours',
        'minutes',
        'seconds',
      ]),
    );
  } else {
    return 'N/A';
  }
}
github eropple / taskbotjs / client / src / Client / index.ts View on Github external
async getDatedMetrics(start: DateTime, end: DateTime): Promise {
    start = start.startOf("day");
    end = end.startOf("day");

    if (end < start) {
      const t = end;
      end = start;
      start = t;
    }

    const interval = Interval.fromDateTimes(start, end);
    const dates = _.concat(interval.splitBy({ days: 1 }).map((i) => i.start), [end]);

    const ret: MetricDayRange = {};

    for (let date of dates) {
      const ymd = date.toFormat(LUXON_YMD);
      const keys = [
        `metrics/processed/${ymd}`,
        `metrics/errored/${ymd}`,
        `metrics/completed/${ymd}`,
        `metrics/died/${ymd}`
      ];
      const resp = await this.asyncRedis.mget(...keys);
      ret[ymd] = {
        processed: parseInt(resp[0] || "0", 10),
        errored: parseInt(resp[1] || "0", 10),
github unscrollinc / unscroll / client / src / components / Timeline / Timelist.js View on Github external
setPosition(dt) {
        const newInterval = Interval.fromDateTimes(
            this.state.interval.start,
            DateTime.fromISO(dt)
        );
        const perc = Math.floor(
            100 *
                (newInterval.length('seconds') /
                    this.state.interval.length('seconds'))
        );
        this.setState({ slide: perc });
    }