How to use the @grafana/ui/src/utils/moment_wrapper.toUtc function in @grafana/ui

To help you get started, we’ve selected a few @grafana/ui 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 grafana / grafana / public / app / features / explore / TimePicker.tsx View on Github external
const timespan = (range.to.valueOf() - range.from.valueOf()) / 2;
    let to, from;

    if (direction === -1) {
      to = range.to.valueOf() - timespan;
      from = range.from.valueOf() - timespan;
    } else if (direction === 1) {
      to = range.to.valueOf() + timespan;
      from = range.from.valueOf() + timespan;
    } else {
      to = range.to.valueOf();
      from = range.from.valueOf();
    }

    const nextTimeRange = {
      from: this.props.timeZone === 'utc' ? toUtc(from) : dateTime(from),
      to: this.props.timeZone === 'utc' ? toUtc(to) : dateTime(to),
    };

    if (onChangeTime) {
      onChangeTime(nextTimeRange);
    }
    return nextTimeRange;
  }
github grafana / grafana / public / app / features / explore / TimePicker.tsx View on Github external
state => {
        const { toRaw, fromRaw } = this.state;
        rawRange = {
          from: fromRaw,
          to: toRaw,
        };

        if (rawRange.from.indexOf('now') === -1) {
          rawRange.from = timeZone === 'utc' ? toUtc(rawRange.from, TIME_FORMAT) : dateTime(rawRange.from, TIME_FORMAT);
        }

        if (rawRange.to.indexOf('now') === -1) {
          rawRange.to = timeZone === 'utc' ? toUtc(rawRange.to, TIME_FORMAT) : dateTime(rawRange.to, TIME_FORMAT);
        }

        const rangeString = rangeUtil.describeTimeRange(rawRange);
        return {
          isOpen: false,
          rangeString,
        };
      },
      () => {
github grafana / grafana / public / app / features / explore / TimePicker.tsx View on Github external
move(direction: number, scanning?: boolean): RawTimeRange {
    const { onChangeTime, range: origRange } = this.props;
    const range = {
      from: toUtc(origRange.from),
      to: toUtc(origRange.to),
    };

    const timespan = (range.to.valueOf() - range.from.valueOf()) / 2;
    let to, from;

    if (direction === -1) {
      to = range.to.valueOf() - timespan;
      from = range.from.valueOf() - timespan;
    } else if (direction === 1) {
      to = range.to.valueOf() + timespan;
      from = range.from.valueOf() + timespan;
    } else {
      to = range.to.valueOf();
      from = range.from.valueOf();
    }
github grafana / grafana / public / app / features / explore / TimePicker.tsx View on Github external
state => {
        const { toRaw, fromRaw } = this.state;
        rawRange = {
          from: fromRaw,
          to: toRaw,
        };

        if (rawRange.from.indexOf('now') === -1) {
          rawRange.from = timeZone === 'utc' ? toUtc(rawRange.from, TIME_FORMAT) : dateTime(rawRange.from, TIME_FORMAT);
        }

        if (rawRange.to.indexOf('now') === -1) {
          rawRange.to = timeZone === 'utc' ? toUtc(rawRange.to, TIME_FORMAT) : dateTime(rawRange.to, TIME_FORMAT);
        }

        const rangeString = rangeUtil.describeTimeRange(rawRange);
        return {
          isOpen: false,
          rangeString,
        };
      },
      () => {
github grafana / grafana / public / app / features / dashboard / components / TimePicker / TimePickerCtrl.ts View on Github external
if (direction === -1) {
      to = range.to.valueOf() - timespan;
      from = range.from.valueOf() - timespan;
    } else if (direction === 1) {
      to = range.to.valueOf() + timespan;
      from = range.from.valueOf() + timespan;
      if (to > Date.now() && range.to < Date.now()) {
        to = Date.now();
        from = range.from.valueOf();
      }
    } else {
      to = range.to.valueOf();
      from = range.from.valueOf();
    }

    this.timeSrv.setTime({ from: toUtc(from), to: toUtc(to) });
  }
github grafana / grafana / public / app / features / explore / TimePicker.tsx View on Github external
let to, from;

    if (direction === -1) {
      to = range.to.valueOf() - timespan;
      from = range.from.valueOf() - timespan;
    } else if (direction === 1) {
      to = range.to.valueOf() + timespan;
      from = range.from.valueOf() + timespan;
    } else {
      to = range.to.valueOf();
      from = range.from.valueOf();
    }

    const nextTimeRange = {
      from: this.props.timeZone === 'utc' ? toUtc(from) : dateTime(from),
      to: this.props.timeZone === 'utc' ? toUtc(to) : dateTime(to),
    };

    if (onChangeTime) {
      onChangeTime(nextTimeRange);
    }
    return nextTimeRange;
  }
github grafana / grafana / public / app / features / explore / TimePicker.tsx View on Github external
move(direction: number, scanning?: boolean): RawTimeRange {
    const { onChangeTime, range: origRange } = this.props;
    const range = {
      from: toUtc(origRange.from),
      to: toUtc(origRange.to),
    };

    const timespan = (range.to.valueOf() - range.from.valueOf()) / 2;
    let to, from;

    if (direction === -1) {
      to = range.to.valueOf() - timespan;
      from = range.from.valueOf() - timespan;
    } else if (direction === 1) {
      to = range.to.valueOf() + timespan;
      from = range.from.valueOf() + timespan;
    } else {
      to = range.to.valueOf();
      from = range.from.valueOf();
    }