How to use the luxon.DateTime.fromMillis 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
DateTime.fromJSDate(new Date(), { foo: "bar" });
// $ExpectError
DateTime.fromJSDate(new Date(), { zone: 2 });
// $ExpectError
DateTime.fromJSDate(new Date(), { locale: 2 });
// $ExpectError
DateTime.fromJSDate(new Date(), { setZone: "yes" });
// $ExpectError
DateTime.fromJSDate(new Date(), { outputCalendar: 2 });
// $ExpectError
DateTime.fromJSDate(new Date(), { numberingSystem: 2 });

var date: DateTime = DateTime.fromMillis(123412323);
DateTime.fromMillis(123412323, {});
DateTime.fromMillis(123412323, { zone: "America/Chicago" });
DateTime.fromMillis(123412323, { zone: new CustomZone() });
DateTime.fromMillis(123412323, { locale: "en-US" });
DateTime.fromMillis(123412323, {
  zone: "America/Chicago",
  setZone: true,
  locale: "en-US",
  outputCalendar: "gregory",
  numberingSystem: "buddhist"
});
// $ExpectError
DateTime.fromMillis();
// $ExpectError
DateTime.fromMillis("1234234123");
// $ExpectError
DateTime.fromMillis(123412323, { foo: "bar" });
// $ExpectError
DateTime.fromMillis(123412323, { zone: 2 });
github artsy / emission / src / lib / Scenes / Artwork / Components / __tests__ / AuctionCountDownTimer-tests.tsx View on Github external
beforeEach(() => {
    jest.useFakeTimers()
    Settings.defaultZoneName = "America/New_York"

    // 2019-08-15T12:00:00.000Z
    Date.now = () => dateNow

    oneDayFromNow = DateTime.fromMillis(dateNow)
      .plus({ days: 1 })
      .toISO()

    oneYearAgo = DateTime.fromMillis(dateNow)
      .minus({ years: 1 })
      .toISO()

    oneDayAgo = DateTime.fromMillis(dateNow)
      .minus({ days: 1 })
      .toISO()
  })
github flow-typed / flow-typed / definitions / npm / luxon_v0.2.x / flow_v0.104.x- / test_luxon.js View on Github external
DateTime.fromJSDate(new Date(), { foo: "bar" });
// $ExpectError
DateTime.fromJSDate(new Date(), { zone: 2 });
// $ExpectError
DateTime.fromJSDate(new Date(), { locale: 2 });
// $ExpectError
DateTime.fromJSDate(new Date(), { setZone: "yes" });
// $ExpectError
DateTime.fromJSDate(new Date(), { outputCalendar: 2 });
// $ExpectError
DateTime.fromJSDate(new Date(), { numberingSystem: 2 });

var date: DateTime = DateTime.fromMillis(123412323);
DateTime.fromMillis(123412323, {});
DateTime.fromMillis(123412323, { zone: "America/Chicago" });
DateTime.fromMillis(123412323, { zone: new CustomZone() });
DateTime.fromMillis(123412323, { locale: "en-US" });
DateTime.fromMillis(123412323, {
  zone: "America/Chicago",
  setZone: true,
  locale: "en-US",
  outputCalendar: "gregory",
  numberingSystem: "buddhist"
});
// $ExpectError
DateTime.fromMillis();
// $ExpectError
DateTime.fromMillis("1234234123");
// $ExpectError
DateTime.fromMillis(123412323, { foo: "bar" });
// $ExpectError
DateTime.fromMillis(123412323, { zone: 2 });
github artsy / emission / src / lib / Scenes / Artwork / Components / __tests__ / AuctionCountDownTimer-tests.tsx View on Github external
beforeEach(() => {
    jest.useFakeTimers()
    Settings.defaultZoneName = "America/New_York"

    // 2019-08-15T12:00:00.000Z
    Date.now = () => dateNow

    oneDayFromNow = DateTime.fromMillis(dateNow)
      .plus({ days: 1 })
      .toISO()

    oneYearAgo = DateTime.fromMillis(dateNow)
      .minus({ years: 1 })
      .toISO()

    oneDayAgo = DateTime.fromMillis(dateNow)
      .minus({ days: 1 })
      .toISO()
  })
github flow-typed / flow-typed / definitions / npm / luxon_v0.4.x / flow_v0.104.x- / test_luxon.js View on Github external
var date: DateTime = DateTime.fromMillis(123412323);
DateTime.fromMillis(123412323, {});
DateTime.fromMillis(123412323, { zone: "America/Chicago" });
DateTime.fromMillis(123412323, { zone: new CustomZone() });
DateTime.fromMillis(123412323, { locale: "en-US" });
DateTime.fromMillis(123412323, {
  zone: "America/Chicago",
  setZone: true,
  locale: "en-US",
  outputCalendar: "gregory",
  numberingSystem: "buddhist"
});
// $ExpectError
DateTime.fromMillis();
// $ExpectError
DateTime.fromMillis("1234234123");
// $ExpectError
DateTime.fromMillis(123412323, { foo: "bar" });
// $ExpectError
DateTime.fromMillis(123412323, { zone: 2 });
// $ExpectError
DateTime.fromMillis(123412323, { locale: 2 });
// $ExpectError
DateTime.fromMillis(123412323, { setZone: "yes" });
// $ExpectError
DateTime.fromMillis(123412323, { outputCalendar: 2 });
// $ExpectError
DateTime.fromMillis(123412323, { numberingSystem: 2 });

var date: DateTime = DateTime.fromRFC2822("12/15/2017, 12:47:25 PM");
DateTime.fromRFC2822("12/15/2017, 12:47:25 PM", {});
DateTime.fromRFC2822("12/15/2017, 12:47:25 PM", { zone: "America/Chicago" });
github fullstack-build / fullstack-one / packages / auth / lib / AuthProvider.ts View on Github external
private async createRandomAuthFactor(): Promise<{ authFactor: IAuthFactorForProof; passwordData: IPasswordData }> {
    const randomPassword = generateRandomPassword();
    const sodiumConfig = createConfig(this.authConfig.sodium);
    const passwordData = await newHash(randomPassword, sodiumConfig);

    const randomTime = DateTime.fromMillis(Math.round(Date.now() * Math.random()), { zone: "utc" }).toISO();

    // Create a fake auth-factor
    const authFactor = {
      id: uuid.v4(),
      meta: JSON.stringify({ sodiumMeta: passwordData.meta, providerMeta: {} }),
      communicationAddress: null,
      createdAt: randomTime,
      userAuthenticationId: uuid.v4(),
      userId: uuid.v4()
    };

    return {
      authFactor,
      passwordData
    };
  }
github elastic / elastic-charts / stories / scales.tsx View on Github external
tickFormat={(d) => {
              return DateTime.fromMillis(d).toFormat('yyyy-MM-dd HH:mm:ss');
            }}
          />
github eropple / taskbotjs / service / src / Server / Metrics / index.ts View on Github external
this.server.onJobComplete(async (jd: JobDescriptor) => {
      const date = DateTime.fromMillis(jd.status!.endedAt!, { zone: "UTC" }).toFormat(LUXON_YMD);
      const allKey = "metrics/completed";
      const dateKey = "metrics/completed/" + date;
      await this.withClient(async (taskbot) => {
        await taskbot.incrementCounter(allKey);
        await taskbot.incrementCounter(dateKey);
      });
    });
github microsoft / pai / src / webportal / src / app / components / util / job.js View on Github external
export function getJobDuration(jobInfo) {
  const start =
    get(jobInfo, 'createdTime') && DateTime.fromMillis(jobInfo.createdTime)
  const end =
    get(jobInfo, 'completedTime') && DateTime.fromMillis(jobInfo.completedTime)
  if (start) {
    return Interval.fromDateTimes(start, end || DateTime.utc()).toDuration([
      'days',
      'hours',
      'minutes',
      'seconds',
    ])
  }
  return null
}