當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。