How to use the luxon.DateTime.fromISO 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 sbb-design-systems / sbb-angular / docker / app.js View on Github external
constructor(packageInfo, tag) {
    this.name = packageInfo.name;
    this.tag = tag;
    this.version = packageInfo['dist-tags'][this.tag];
    this.dateTime = DateTime.fromISO(
      packageInfo.time[this.version], { locale: 'de', zone: 'Europe/Zurich' });
    this.targetDir = join(__dirname, 'browser', this.tag);
    this.installName = `sbb-angular-showcase-${this.tag}@npm:sbb-angular-showcase@${this.tag}`;
    this.location = join(__dirname, 'node_modules', `sbb-angular-showcase-${this.tag}`);
  }
github swiftyapp / swifty / src / renderer / javascripts / components / main / body / aside / show / index.js View on Github external
const formatDate = str => {
    return DateTime.fromISO(str).toLocaleString(DateTime.DATETIME_MED)
  }
github lmammino / public-transport-ireland / src / luas.ts View on Github external
export async function getRealTimeInfo (stopCode: string, directionFilter?: Direction): Promise> {
  const response = await got(SERVICE_URI, {
    query: {
      action: 'forecast',
      stop: stopCode,
      ver: 2,
      encrypt: false
    }
  })

  const document: StopRealTimeInfoResponse = await parseXml(response.body)

  const trams : Array = []

  const requestTime = DateTime.fromISO(document.stopInfo.$.created, { zone: 'Europe/Dublin' })

  document.stopInfo.direction.forEach((direction) => {
    direction.tram.forEach((tram) => {
      const dueMins = tram.$.dueMins === 'DUE' ? 0 : Number(tram.$.dueMins)
      trams.push({
        direction: direction.$.name,
        destination: tram.$.destination,
        arrivingInMinutes: dueMins,
        expectedArrivalTime: requestTime.plus({ minutes: dueMins }).toString()
      })
    })
  })

  if (directionFilter) {
    return trams.filter(tram => tram.direction === directionFilter)
  }
github pekkis / hardcore-react-training / client / src / services / person.js View on Github external
const calculateAge = p => {
  const now = DateTime.local();
  const bd = DateTime.fromISO(p.birthDay);
  const age = now.diff(bd, "years").toObject().years;
  return {
    ...p,
    age
  };
};
github photoprism / photoprism / frontend / src / model / label.js View on Github external
getDateString() {
        return DateTime.fromISO(this.CreatedAt).toLocaleString(DateTime.DATETIME_MED);
    }
github elastic / elastic-charts / stories / scales.tsx View on Github external
import { select, boolean } from '@storybook/addon-knobs';
import { storiesOf } from '@storybook/react';
import { DateTime } from 'luxon';
import React from 'react';
import { Axis, Chart, getAxisId, getSpecId, LineSeries, Position, ScaleType, Settings } from '../src';

const today = new Date().getTime();
const UTC_DATE = DateTime.fromISO('2019-01-01T00:00:00.000Z').toMillis();
const UTC_PLUS8_DATE = DateTime.fromISO('2019-01-01T00:00:00.000+08:00', {
  setZone: true,
}).toMillis();
const UTC_MINUS8_DATE = DateTime.fromISO('2019-01-01T00:00:00.000-08:00', {
  setZone: true,
}).toMillis();
const DAY_INCREMENT_1 = 1000 * 60 * 60 * 24;
const UTC_DATASET = new Array(10).fill(0).map((d, i) => {
  return [UTC_DATE + DAY_INCREMENT_1 * i, i % 5];
});
const CURRENT_TIMEZONE_DATASET = new Array(10).fill(0).map((d, i) => {
  return [today + DAY_INCREMENT_1 * i, i % 5];
});
const OTHER_PLUS8_TIMEZONE_DATASET = new Array(10).fill(0).map((d, i) => {
  return [UTC_PLUS8_DATE + DAY_INCREMENT_1 * i, i % 5];
});
const OTHER_MINUS8_TIMEZONE_DATASET = new Array(10).fill(0).map((d, i) => {
  return [UTC_MINUS8_DATE + DAY_INCREMENT_1 * i, i % 5];
});
github brave / ethereum-remote-client / ui / app / components / app / dai-migration-component / dai-migration-notification.component.js View on Github external
render () {
    const { t } = this.context
    const { mkrMigrationReminderTimestamp, string: balanceString, symbol } = this.props

    if (mkrMigrationReminderTimestamp) {
      const reminderDateTime = DateTime.fromISO(mkrMigrationReminderTimestamp, {
        zone: 'UTC',
      })
      if (reminderDateTime > DateTime.utc()) {
        return null
      }
    }

    if (!balanceString || !symbol) {
      return null
    }

    if (balanceString === '0') {
      return null
    }

    return (
github Thorium-Sim / thorium / client / src / components / views / Records / core.js View on Github external
.map(r => (
              <p> setSelectedRecord(r.id)}
              &gt;
                {new DateTime.fromISO(r.timestamp).toLocaleString(
                  DateTime.TIME_SIMPLE
                )}{" "}
                - {titleCase(r.category)}: {r.contents}
              </p>
            ))}
github unscrollinc / unscroll / client / src / components / Timeline / TimelistTitleEditor.js View on Github external
quickDate(iso) {
        return DateTime.fromISO(iso).toFormat('d MMM kkkk');
    }
    renderDeleteModal() {
github photoprism / photoprism / frontend / src / model / album.js View on Github external
getDateString() {
        return DateTime.fromISO(this.CreatedAt).toLocaleString(DateTime.DATETIME_MED);
    }