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


TypeScript moment_wrapper.dateTime函数代码示例

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


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

示例1: beforeEach

 beforeEach(() => {
   ctx.query = {
     range: { from: dateTime(1443454528000), to: dateTime(1443454528000) },
     targets: [{ expr: 'test{job="testjob"}', format: 'heatmap', legendFormat: '{{le}}' }],
     interval: '1s',
   };
 });
开发者ID:grafana,项目名称:grafana,代码行数:7,代码来源:datasource.test.ts

示例2: plotOptionsScenario

    plotOptionsScenario('for day of week region', ctx => {
      const regions = [{ fromDayOfWeek: 1, toDayOfWeek: 1, fill: true, line: true, colorMode: 'red' }];
      const from = dateTime('2018-01-01T00:00:00+01:00');
      const to = dateTime('2018-01-01T23:59:00+01:00');
      ctx.setup(regions, from, to);

      it('should add 3 markings', () => {
        expect(ctx.options.grid.markings.length).toBe(3);
      });

      it('should add fill', () => {
        const markings = ctx.options.grid.markings;
        expect(dateTime(markings[0].xaxis.from).format()).toBe(dateTime('2018-01-01T01:00:00+01:00').format());
        expect(dateTime(markings[0].xaxis.to).format()).toBe(dateTime('2018-01-02T00:59:59+01:00').format());
        expect(markings[0].color).toBe(colorModes.red.color.fill);
      });

      it('should add line before', () => {
        const markings = ctx.options.grid.markings;
        expect(dateTime(markings[1].xaxis.from).format()).toBe(dateTime('2018-01-01T01:00:00+01:00').format());
        expect(dateTime(markings[1].xaxis.to).format()).toBe(dateTime('2018-01-01T01:00:00+01:00').format());
        expect(markings[1].color).toBe(colorModes.red.color.line);
      });

      it('should add line after', () => {
        const markings = ctx.options.grid.markings;
        expect(dateTime(markings[2].xaxis.from).format()).toBe(dateTime('2018-01-02T00:59:59+01:00').format());
        expect(dateTime(markings[2].xaxis.to).format()).toBe(dateTime('2018-01-02T00:59:59+01:00').format());
        expect(markings[2].color).toBe(colorModes.red.color.line);
      });
    });
开发者ID:grafana,项目名称:grafana,代码行数:31,代码来源:time_region_manager.test.ts

示例3:

 ctx.options.grid.markings.forEach((m: any, i: number) => {
   console.log(
     `Marking (${i}): from=${dateTime(m.xaxis.from).format()}, to=${dateTime(m.xaxis.to).format()}, color=${
       m.color
     }`
   );
 });
开发者ID:grafana,项目名称:grafana,代码行数:7,代码来源:time_region_manager.test.ts

示例4: return

 return (date: string, mode: string) => {
   switch (mode) {
     case 'ago':
       return dateTime(date).fromNow();
   }
   return dateTime(date).fromNow();
 };
开发者ID:grafana,项目名称:grafana,代码行数:7,代码来源:filters.ts

示例5: beforeEach

    beforeEach(() => {
      createDatasource({
        url: 'http://es.com',
        index: 'test',
        jsonData: { esVersion: '5' },
      });

      ctx.backendSrv.datasourceRequest = jest.fn(options => {
        requestOptions = options;
        return Promise.resolve({ data: { responses: [] } });
      });

      ctx.ds.query({
        range: {
          from: dateTime([2015, 4, 30, 10]),
          to: dateTime([2015, 5, 1, 10]),
        },
        targets: [
          {
            bucketAggs: [{ type: 'date_histogram', field: '@timestamp', id: '2' }],
            metrics: [{ type: 'count' }],
            query: 'test',
          },
        ],
      });

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

示例6: describe

  describe('When performing annotationQuery', () => {
    let results;

    const annotationName = 'MyAnno';

    const options = {
      annotation: {
        name: annotationName,
        rawQuery: 'select time, text, tags from table;',
      },
      range: {
        from: dateTime(1432288354),
        to: dateTime(1432288401),
      },
    };

    const response = {
      results: {
        MyAnno: {
          refId: annotationName,
          tables: [
            {
              columns: [{ text: 'time' }, { text: 'text' }, { text: 'tags' }],
              rows: [
                [1521545610656, 'some text', 'TagA,TagB'],
                [1521546251185, 'some text2', ' TagB , TagC'],
                [1521546501378, 'some text3'],
              ],
            },
          ],
        },
      },
    };

    beforeEach(() => {
      ctx.backendSrv.datasourceRequest = options => {
        return ctx.$q.when({ data: response, status: 200 });
      };

      return ctx.ds.annotationQuery(options).then(data => {
        results = data;
      });
    });

    it('should return annotation list', () => {
      expect(results.length).toBe(3);

      expect(results[0].text).toBe('some text');
      expect(results[0].tags[0]).toBe('TagA');
      expect(results[0].tags[1]).toBe('TagB');

      expect(results[1].tags[0]).toBe('TagB');
      expect(results[1].tags[1]).toBe('TagC');

      expect(results[2].tags.length).toBe(0);
    });
  });
开发者ID:grafana,项目名称:grafana,代码行数:57,代码来源:datasource.test.ts


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