How to use the luxon.Instant.fromObject 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 moment / luxon / test / instant / create.js View on Github external
it('Instant.fromObject() takes a zone option', () => {
    let daylight = Instant.fromObject(Object.assign({}, baseObject, {month: 5}), {zone: new FakePT()}),
        standard = Instant.fromObject(Object.assign({}, baseObject, {month: 12}), {zone: new FakePT()});

    expect(daylight.isOffsetFixed()).toBe(false);
    expect(daylight.offset()).toBe(-7 * 60);
    expect(daylight.year()).toBe(1982);
    expect(daylight.month()).toBe(5);
    expect(daylight.day()).toBe(25);
    expect(daylight.hour()).toBe(9);
    expect(daylight.minute()).toBe(23);
    expect(daylight.second()).toBe(54);
    expect(daylight.millisecond()).toBe(123);

    expect(standard.isOffsetFixed()).toBe(false);
    expect(standard.offset()).toBe(-8 * 60);
    expect(standard.year()).toBe(1982);
    expect(standard.month()).toBe(12);
    expect(standard.day()).toBe(25);
github moment / luxon / test / instant / create.instant.spec.js View on Github external
it('sets all the fields', () => {

        let instant = Instant.fromObject({
          year: 1982,
          month: 5,
          day: 25,
          hour: 9,
          minute: 23,
          second: 54,
          millisecond: 123
        });

        instant.isOffsetFixed().should.equal(false);
        instant.year().should.equal(1982);
        instant.month().should.equal(5);
        instant.day().should.equal(25);
        instant.hour().should.equal(9);
        instant.minute().should.equal(23);
        instant.second().should.equal(54);
github moment / luxon / test / instant / create.js View on Github external
it('Instant.fromObject() defaults high-order values to the current date', () => {
    let instant = Instant.fromObject({}),
        now = Instant.now();

    expect(instant.year()).toBe(now.year());
    expect(instant.month()).toBe(now.month());
    expect(instant.day()).toBe(now.day());
  });
github moment / luxon / test / instant / create.instant.spec.js View on Github external
it('defaults lower-order values to 0', () => {

        let instant = Instant.fromObject({});

        instant.hour().should.equal(0),
        instant.minute().should.equal(0),
        instant.second().should.equal(0),
        instant.millisecond().should.equal(0);
      });
    });
github moment / luxon / test / instant / create.js View on Github external
it('Instant.fromObject() takes a zone option', () => {
    let daylight = Instant.fromObject(Object.assign({}, baseObject, {month: 5}), {zone: new FakePT()}),
        standard = Instant.fromObject(Object.assign({}, baseObject, {month: 12}), {zone: new FakePT()});

    expect(daylight.isOffsetFixed()).toBe(false);
    expect(daylight.offset()).toBe(-7 * 60);
    expect(daylight.year()).toBe(1982);
    expect(daylight.month()).toBe(5);
    expect(daylight.day()).toBe(25);
    expect(daylight.hour()).toBe(9);
    expect(daylight.minute()).toBe(23);
    expect(daylight.second()).toBe(54);
    expect(daylight.millisecond()).toBe(123);

    expect(standard.isOffsetFixed()).toBe(false);
    expect(standard.offset()).toBe(-8 * 60);
    expect(standard.year()).toBe(1982);
    expect(standard.month()).toBe(12);
github moment / luxon / test / interval / create.js View on Github external
it('Interval.fromObject creates an interval', () => {
    let start = Instant.fromObject({year: 2016, month: 5, day: 25}),
        end = Instant.fromObject({year: 2016, month: 5, day: 27}),
        int = Interval.fromInstants(start, end);

    expect(int.start()).toBe(start);
    expect(int.end()).toBe(end);
  });
github moment / luxon / test / instant / create.instant.spec.js View on Github external
it('allows a zone to be specified', () => {
        let base = {
          year: 1982,
          day: 25,
          hour: 9,
          minute: 23,
          second: 54,
          millisecond: 123
        },
            daylight = Instant.fromObject(Object.assign({}, base, {month: 5}), {zone: new FakePT()}),
            standard = Instant.fromObject(Object.assign({}, base, {month: 12}), {zone: new FakePT()});

        daylight.isOffsetFixed().should.equal(false);
        daylight.offset().should.equal(-7 * 60);
        daylight.year().should.equal(1982);
        daylight.month().should.equal(5);
        daylight.day().should.equal(25);
        daylight.hour().should.equal(9);
        daylight.minute().should.equal(23);
        daylight.second().should.equal(54);
        daylight.millisecond().should.equal(123);

        standard.isOffsetFixed().should.equal(false);
        standard.offset().should.equal(-8 * 60);
        standard.year().should.equal(1982);
        standard.month().should.equal(12);
github moment / luxon / test / instant / diff.js View on Github external
  let diffFromObjs = (o1, o2, ...units) => Instant.fromObject(o1).diff(Instant.fromObject(o2), ...units),
      diffObjs = (o1, o2, ...units) => diffFromObjs(o1, o2, ...units).toObject();
github moment / luxon / test / instant / math.js View on Github external
function createInstant(){
  return Instant.fromObject({
    year: 2010,
    month: 2,
    day: 3,
    hour: 4,
    minute: 5,
    second: 6,
    millisecond: 7
  });
}
github moment / luxon / test / instant / format.js View on Github external
  let inst = () => Instant.fromObject({year: 1982, month: 5, day: 25, hour: 9, minute: 23, second: 54, millisecond: 123}, {utc: true});