How to use the @grafana/ui/src/utils/moment_wrapper.dateTime 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
getAbsoluteMomentForTimezone(jsDate) {
    return this.dashboard.isTimezoneUtc() ? dateTime(jsDate).utc() : dateTime(jsDate);
  }
github grafana / grafana / public / app / core / utils / file_export.ts View on Github external
export function convertSeriesListToCsv(seriesList, dateTimeFormat = DEFAULT_DATETIME_FORMAT, excel = false) {
  let text = formatSpecialHeader(excel) + formatRow(['Series', 'Time', 'Value']);
  for (let seriesIndex = 0; seriesIndex < seriesList.length; seriesIndex += 1) {
    for (let i = 0; i < seriesList[seriesIndex].datapoints.length; i += 1) {
      text += formatRow(
        [
          seriesList[seriesIndex].alias,
          dateTime(seriesList[seriesIndex].datapoints[i][POINT_TIME_INDEX]).format(dateTimeFormat),
          seriesList[seriesIndex].datapoints[i][POINT_VALUE_INDEX],
        ],
        i < seriesList[seriesIndex].datapoints.length - 1 || seriesIndex < seriesList.length - 1
      );
    }
  }
  return text;
}
github grafana / grafana / public / app / plugins / datasource / grafana-azure-monitor-datasource / log_analytics / querystring_builder.ts View on Github external
getFrom(options: any) {
    const from = options.range.from;
    return `datetime(${dateTime(from)
      .startOf('minute')
      .toISOString()})`;
  }
github grafana / grafana / public / app / plugins / datasource / grafana-azure-monitor-datasource / log_analytics / querystring_builder.ts View on Github external
getUntil(options: any) {
    if (options.rangeRaw.to === 'now') {
      const now = Date.now();
      return `datetime(${dateTime(now)
        .startOf('minute')
        .toISOString()})`;
    } else {
      const until = options.range.to;
      return `datetime(${dateTime(until)
        .startOf('minute')
        .toISOString()})`;
    }
  }
github grafana / grafana / public / app / plugins / datasource / grafana-azure-monitor-datasource / log_analytics / querystring_builder.ts View on Github external
getUntil(options: any) {
    if (options.rangeRaw.to === 'now') {
      const now = Date.now();
      return `datetime(${dateTime(now)
        .startOf('minute')
        .toISOString()})`;
    } else {
      const until = options.range.to;
      return `datetime(${dateTime(until)
        .startOf('minute')
        .toISOString()})`;
    }
  }
github grafana / grafana / public / app / plugins / datasource / elasticsearch / index_pattern.ts View on Github external
getIndexList(from, to) {
    if (!this.interval) {
      return this.pattern;
    }

    const intervalInfo = intervalMap[this.interval];
    const start = dateTime(from)
      .utc()
      .startOf(intervalInfo.startOf);
    const endEpoch = dateTime(to)
      .utc()
      .startOf(intervalInfo.startOf)
      .valueOf();
    const indexList = [];

    while (start.valueOf() <= endEpoch) {
      indexList.push(start.format(this.pattern));
      start.add(1, intervalInfo.amount);
    }

    return indexList;
  }
}
github grafana / grafana / public / app / plugins / datasource / elasticsearch / index_pattern.ts View on Github external
getIndexList(from, to) {
    if (!this.interval) {
      return this.pattern;
    }

    const intervalInfo = intervalMap[this.interval];
    const start = dateTime(from)
      .utc()
      .startOf(intervalInfo.startOf);
    const endEpoch = dateTime(to)
      .utc()
      .startOf(intervalInfo.startOf)
      .valueOf();
    const indexList = [];

    while (start.valueOf() <= endEpoch) {
      indexList.push(start.format(this.pattern));
      start.add(1, intervalInfo.amount);
    }

    return indexList;
  }
}