当前位置: 首页>>代码示例>>TypeScript>>正文


TypeScript moment_wrapper.toUtc函数代码示例

本文整理汇总了TypeScript中@grafana/ui/src/utils/moment_wrapper.toUtc函数的典型用法代码示例。如果您正苦于以下问题:TypeScript toUtc函数的具体用法?TypeScript toUtc怎么用?TypeScript toUtc使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了toUtc函数的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。

示例1: toUtc

const parseRawTime = (value): TimeFragment => {
  if (value === null) {
    return null;
  }

  if (value.indexOf('now') !== -1) {
    return value;
  }
  if (value.length === 8) {
    return toUtc(value, 'YYYYMMDD');
  }
  if (value.length === 15) {
    return toUtc(value, 'YYYYMMDDTHHmmss');
  }
  // Backward compatibility
  if (value.length === 19) {
    return toUtc(value, 'YYYY-MM-DD HH:mm:ss');
  }

  if (!isNaN(value)) {
    const epoch = parseInt(value, 10);
    return toUtc(epoch);
  }

  return null;
};
开发者ID:grafana,项目名称:grafana,代码行数:26,代码来源:explore.ts

示例2: beforeEach

 beforeEach(() => {
   builder = new AzureMonitorFilterBuilder(
     'Percentage CPU',
     toUtc('2017-08-22 06:00'),
     toUtc('2017-08-22 07:00'),
     'PT1H',
     '3m'
   );
 });
开发者ID:grafana,项目名称:grafana,代码行数:9,代码来源:azure_monitor_filter_builder.test.ts

示例3: zoomOut

  zoomOut(e: any, factor: number) {
    const range = this.timeRange();

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

    const to = center + (timespan * factor) / 2;
    const from = center - (timespan * factor) / 2;

    this.setTime({ from: toUtc(from), to: toUtc(to) });
  }
开发者ID:grafana,项目名称:grafana,代码行数:11,代码来源:TimeSrv.ts

示例4: beforeEach

    beforeEach(async () => {
      createDatasource({
        url: 'http://es.com',
        index: '[asd-]YYYY.MM.DD',
        jsonData: { interval: 'Daily', esVersion: '2' },
      });

      ctx.backendSrv.datasourceRequest = jest.fn(options => {
        requestOptions = options;
        return Promise.resolve({
          data: {
            responses: [
              {
                aggregations: {
                  '1': {
                    buckets: [
                      {
                        doc_count: 10,
                        key: 1000,
                      },
                    ],
                  },
                },
              },
            ],
          },
        });
      });

      query = {
        range: {
          from: toUtc([2015, 4, 30, 10]),
          to: toUtc([2015, 5, 1, 10]),
        },
        targets: [
          {
            alias: '$varAlias',
            bucketAggs: [{ type: 'date_histogram', field: '@timestamp', id: '1' }],
            metrics: [{ type: 'count', id: '1' }],
            query: 'escape\\:test',
          },
        ],
      };

      result = await ctx.ds.query(query);

      parts = requestOptions.data.split('\n');
      header = angular.fromJson(parts[0]);
    });
开发者ID:grafana,项目名称:grafana,代码行数:49,代码来源:datasource.test.ts

示例5: toUtc

      const fromUser = text => {
        if (text.indexOf('now') !== -1) {
          if (!dateMath.isValid(text)) {
            ngModel.$setValidity('error', false);
            return undefined;
          }
          ngModel.$setValidity('error', true);
          return text;
        }

        let parsed;
        if ($scope.ctrl.isUtc) {
          parsed = toUtc(text, format);
        } else {
          parsed = dateTime(text, format);
        }

        if (!parsed.isValid()) {
          ngModel.$setValidity('error', false);
          return undefined;
        }

        ngModel.$setValidity('error', true);
        return parsed;
      };
开发者ID:grafana,项目名称:grafana,代码行数:25,代码来源:validation.ts

示例6: getIndexForToday

 getIndexForToday() {
   if (this.interval) {
     return toUtc().format(this.pattern);
   } else {
     return this.pattern;
   }
 }
开发者ID:grafana,项目名称:grafana,代码行数:7,代码来源:index_pattern.ts

示例7: describe

  describe('When performing query', () => {
    const options = {
      range: {
        from: toUtc('2017-08-22T20:00:00Z'),
        to: toUtc('2017-08-22T23:59:00Z'),
      },
      rangeRaw: {
        from: 'now-4h',
        to: 'now',
      },
      targets: [
        {
          refId: 'A',
        },
      ],
    };

    describe('and no time series data is returned', () => {
      let ds;
      const response = {
        results: {
          A: {
            refId: 'A',
            meta: {
              rawQuery: 'arawquerystring',
            },
            series: null,
            tables: null,
          },
        },
      };

      beforeEach(() => {
        const backendSrv = ({
          datasourceRequest: async () => Promise.resolve({ status: 200, data: response }),
        } as unknown) as BackendSrv;
        ds = new StackdriverDataSource(instanceSettings, backendSrv, templateSrv, timeSrv);
      });

      it('should return a list of datapoints', () => {
        return ds.query(options).then(results => {
          expect(results.data.length).toBe(0);
        });
      });
    });
  });
开发者ID:grafana,项目名称:grafana,代码行数:46,代码来源:datasource.test.ts

示例8: parseUrlParam

  private parseUrlParam(value: any) {
    if (value.indexOf('now') !== -1) {
      return value;
    }
    if (value.length === 8) {
      return toUtc(value, 'YYYYMMDD');
    }
    if (value.length === 15) {
      return toUtc(value, 'YYYYMMDDTHHmmss');
    }

    if (!isNaN(value)) {
      const epoch = parseInt(value, 10);
      return toUtc(epoch);
    }

    return null;
  }
开发者ID:grafana,项目名称:grafana,代码行数:18,代码来源:TimeSrv.ts

示例9: onMouseUp

  onMouseUp() {
    $(document).unbind('mouseup', this.mouseUpHandler.bind(this));
    this.mouseUpHandler = null;
    this.selection.active = false;

    const selectionRange = Math.abs(this.selection.x2 - this.selection.x1);
    if (this.selection.x2 >= 0 && selectionRange > MIN_SELECTION_WIDTH) {
      const timeFrom = this.xScale.invert(Math.min(this.selection.x1, this.selection.x2) - this.yAxisWidth);
      const timeTo = this.xScale.invert(Math.max(this.selection.x1, this.selection.x2) - this.yAxisWidth);

      this.ctrl.timeSrv.setTime({
        from: toUtc(timeFrom),
        to: toUtc(timeTo),
      });
    }

    this.clearSelection();
  }
开发者ID:grafana,项目名称:grafana,代码行数:18,代码来源:rendering.ts

示例10: getFieldFromSource

    return this.post('_msearch', payload).then(res => {
      const list = [];
      const hits = res.responses[0].hits.hits;

      const getFieldFromSource = (source, fieldName) => {
        if (!fieldName) {
          return;
        }

        const fieldNames = fieldName.split('.');
        let fieldValue = source;

        for (let i = 0; i < fieldNames.length; i++) {
          fieldValue = fieldValue[fieldNames[i]];
          if (!fieldValue) {
            console.log('could not find field in annotation: ', fieldName);
            return '';
          }
        }

        return fieldValue;
      };

      for (let i = 0; i < hits.length; i++) {
        const source = hits[i]._source;
        let time = getFieldFromSource(source, timeField);
        if (typeof hits[i].fields !== 'undefined') {
          const fields = hits[i].fields;
          if (_.isString(fields[timeField]) || _.isNumber(fields[timeField])) {
            time = fields[timeField];
          }
        }

        const event = {
          annotation: annotation,
          time: toUtc(time).valueOf(),
          text: getFieldFromSource(source, textField),
          tags: getFieldFromSource(source, tagsField),
        };

        // legacy support for title tield
        if (annotation.titleField) {
          const title = getFieldFromSource(source, annotation.titleField);
          if (title) {
            event.text = title + '\n' + event.text;
          }
        }

        if (typeof event.tags === 'string') {
          event.tags = event.tags.split(',');
        }

        list.push(event);
      }
      return list;
    });
开发者ID:grafana,项目名称:grafana,代码行数:56,代码来源:datasource.ts


注:本文中的@grafana/ui/src/utils/moment_wrapper.toUtc函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。