How to use the @grafana/ui/src/utils/moment_wrapper.isDateTime 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 / dashboard / components / TimePicker / TimePickerCtrl.ts View on Github external
timeRaw.from.local();
      }
      if (isDateTime(timeRaw.to)) {
        timeRaw.to.local();
      }
      this.isUtc = false;
    } else {
      this.isUtc = true;
    }

    this.rangeString = rangeUtil.describeTimeRange(timeRaw);
    this.absolute = { fromJs: time.from.toDate(), toJs: time.to.toDate() };
    this.tooltip = this.dashboard.formatDate(time.from) + ' <br>to<br>';
    this.tooltip += this.dashboard.formatDate(time.to);
    this.timeRaw = timeRaw;
    this.isAbsolute = isDateTime(this.timeRaw.to);
  }
github grafana / grafana / public / app / features / dashboard / components / TimePicker / TimePickerCtrl.ts View on Github external
onRefresh() {
    const time = angular.copy(this.timeSrv.timeRange());
    const timeRaw = angular.copy(time.raw);

    if (!this.dashboard.isTimezoneUtc()) {
      time.from.local();
      time.to.local();
      if (isDateTime(timeRaw.from)) {
        timeRaw.from.local();
      }
      if (isDateTime(timeRaw.to)) {
        timeRaw.to.local();
      }
      this.isUtc = false;
    } else {
      this.isUtc = true;
    }

    this.rangeString = rangeUtil.describeTimeRange(timeRaw);
    this.absolute = { fromJs: time.from.toDate(), toJs: time.to.toDate() };
    this.tooltip = this.dashboard.formatDate(time.from) + ' <br>to<br>';
    this.tooltip += this.dashboard.formatDate(time.to);
    this.timeRaw = timeRaw;
    this.isAbsolute = isDateTime(this.timeRaw.to);
  }
github grafana / grafana / public / app / features / explore / TimePicker.tsx View on Github external
const getRaw = (range: any, timeZone: TimeZone) => {
  const rawRange = {
    from: range.raw.from,
    to: range.raw.to,
  };

  if (isDateTime(rawRange.from)) {
    if (timeZone === 'browser') {
      rawRange.from = rawRange.from.local();
    }
    rawRange.from = rawRange.from.format(TIME_FORMAT);
  }

  if (isDateTime(rawRange.to)) {
    if (timeZone === 'browser') {
      rawRange.to = rawRange.to.local();
    }
    rawRange.to = rawRange.to.format(TIME_FORMAT);
  }

  return rawRange;
};
github grafana / grafana / public / app / features / dashboard / components / TimePicker / validation.ts View on Github external
const toUser = currentValue => {
        if (isDateTime(currentValue)) {
          return currentValue.format(format);
        } else {
          return currentValue;
        }
      };
github grafana / grafana / public / app / features / explore / state / epics / stateSaveEpic.ts View on Github external
const toRawTimeRange = (range: TimeRange): RawTimeRange => {
  let from = range.raw.from;
  if (isDateTime(from)) {
    from = from.valueOf().toString(10);
  }

  let to = range.raw.to;
  if (isDateTime(to)) {
    to = to.valueOf().toString(10);
  }

  return {
    from,
    to,
  };
};
github grafana / grafana / public / app / features / dashboard / components / TimePicker / TimePickerCtrl.ts View on Github external
onRefresh() {
    const time = angular.copy(this.timeSrv.timeRange());
    const timeRaw = angular.copy(time.raw);

    if (!this.dashboard.isTimezoneUtc()) {
      time.from.local();
      time.to.local();
      if (isDateTime(timeRaw.from)) {
        timeRaw.from.local();
      }
      if (isDateTime(timeRaw.to)) {
        timeRaw.to.local();
      }
      this.isUtc = false;
    } else {
      this.isUtc = true;
    }

    this.rangeString = rangeUtil.describeTimeRange(timeRaw);
    this.absolute = { fromJs: time.from.toDate(), toJs: time.to.toDate() };
    this.tooltip = this.dashboard.formatDate(time.from) + ' <br>to<br>';
    this.tooltip += this.dashboard.formatDate(time.to);
    this.timeRaw = timeRaw;
    this.isAbsolute = isDateTime(this.timeRaw.to);
github grafana / grafana / public / app / features / explore / state / epics / stateSaveEpic.ts View on Github external
const toRawTimeRange = (range: TimeRange): RawTimeRange => {
  let from = range.raw.from;
  if (isDateTime(from)) {
    from = from.valueOf().toString(10);
  }

  let to = range.raw.to;
  if (isDateTime(to)) {
    to = to.valueOf().toString(10);
  }

  return {
    from,
    to,
  };
};
github grafana / grafana / public / app / features / explore / TimePicker.tsx View on Github external
const getRaw = (range: any, timeZone: TimeZone) => {
  const rawRange = {
    from: range.raw.from,
    to: range.raw.to,
  };

  if (isDateTime(rawRange.from)) {
    if (timeZone === 'browser') {
      rawRange.from = rawRange.from.local();
    }
    rawRange.from = rawRange.from.format(TIME_FORMAT);
  }

  if (isDateTime(rawRange.to)) {
    if (timeZone === 'browser') {
      rawRange.to = rawRange.to.local();
    }
    rawRange.to = rawRange.to.format(TIME_FORMAT);
  }

  return rawRange;
};