• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

TypeScript moment.utc函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: it

    it('should translate index pattern to current day', function() {
      var requestOptions;
      ctx.backendSrv.datasourceRequest = function(options) {
        requestOptions = options;
        return ctx.$q.when({data: {}});
      };

      ctx.ds.testDatasource();
      ctx.$rootScope.$apply();

      var today = moment.utc().format("YYYY.MM.DD");
      expect(requestOptions.url).to.be("http://es.com/asd-" + today + '/_mapping');
    });
开发者ID:shirish87,项目名称:grafana,代码行数:13,代码来源:datasource_specs.ts


示例2: setupRequest

export function setupRequest(req: Legacy.Request): Setup {
  const query = (req.query as unknown) as APMRequestQuery;
  const cluster = req.server.plugins.elasticsearch.getCluster('data');
  const uiSettings = req.getUiSettingsService();
  const config = req.server.config();
  const apmIndices = getApmIndices(config);

  const client: ESClient = async (type, params) => {
    const includeFrozen = await uiSettings.get('search:includeFrozen');

    const nextParams = {
      ...addFilterForLegacyData(apmIndices, params), // filter out pre-7.0 data
      ignore_throttled: !includeFrozen, // whether to query frozen indices or not
      rest_total_hits_as_int: true // ensure that ES returns accurate hits.total with pre-6.6 format
    };

    if (query._debug) {
      console.log(`DEBUG ES QUERY:`);
      console.log('includeFrozen: ', includeFrozen);
      console.log(
        `${req.method.toUpperCase()} ${req.url.pathname} ${JSON.stringify(
          query
        )}`
      );
      console.log(`GET ${nextParams.index}/_search`);
      console.log(JSON.stringify(nextParams.body, null, 4));
    }

    return cluster.callWithRequest(req, type, nextParams);
  };

  return {
    start: moment.utc(query.start).valueOf(),
    end: moment.utc(query.end).valueOf(),
    esFilterQuery: decodeEsQuery(query.esFilterQuery),
    client,
    config
  };
}
开发者ID:spalger,项目名称:kibana,代码行数:39,代码来源:setup_request.ts


示例3: parseInt

 var data = body.results.map((m: any) => {
   return {
     "key" : m.value_1 + "_" + m.value_2 + "_" + m.value_3,
     "source" : "silver-surfer",
     data : {
       "time": moment.utc(m.value_1, "DD.MM.YYYY - HH:mm").toISOString(),
       "ticket": m.value_2,
       "oper": m.value_3 == "Продавать" ? "sell" : "buy",
       "stop": m.number ? m.number : null,
       "force": m.value_4 && m.value_4 != "Штиль" ? parseInt(m.value_4) : null
     }
   }
 });
开发者ID:baio,项目名称:bee-trader-notifiier-silver-surfer,代码行数:13,代码来源:handler.ts


示例4: moment

const withSection = (referenceDateTime: moment.Moment) => (
  message: Message
): MessageWithSection => {
  const today = moment(referenceDateTime).startOf('day');
  const yesterday = moment(referenceDateTime)
    .subtract(1, 'day')
    .startOf('day');
  const thisWeek = moment(referenceDateTime).startOf('isoWeek');
  const thisMonth = moment(referenceDateTime).startOf('month');

  const messageReceivedDate = moment.utc(message.received_at);
  if (messageReceivedDate.isAfter(today)) {
    return {
      order: 0,
      type: 'today',
      message,
    };
  }
  if (messageReceivedDate.isAfter(yesterday)) {
    return {
      order: 1,
      type: 'yesterday',
      message,
    };
  }
  if (messageReceivedDate.isAfter(thisWeek)) {
    return {
      order: 2,
      type: 'thisWeek',
      message,
    };
  }
  if (messageReceivedDate.isAfter(thisMonth)) {
    return {
      order: 3,
      type: 'thisMonth',
      message,
    };
  }

  const month: number = messageReceivedDate.month();
  const year: number = messageReceivedDate.year();

  return {
    order: year * 100 + month,
    type: 'yearMonth',
    month,
    year,
    message,
  };
};
开发者ID:VetoPlayer,项目名称:Signal-Desktop,代码行数:51,代码来源:groupMessagesByDate.ts


示例5: parseTimeStamp

 parseTimeStamp(dateTime: string, format: string): moment.Moment {
     try {
         let m = moment.utc(dateTime, format, false);
         if (!m.isValid()) {
             console.warn("Cannot parse TimeStamp. dateTime=" + dateTime + "; format=" + format);
             return null;
         }
         return m;
     }
     catch (ex) {
         console.warn(ex);
         return null;
     }
 }
开发者ID:Koopakiller,项目名称:MultiDimensional-MindManager,代码行数:14,代码来源:Parser.ts


示例6:

  var tasks = textData.split(/\r|\n|\r\n/).map(function (line) {
    line = line.replace(///g, "/");
    line = line.replace(/ /g, " ");
    line = line.replace(/〜/g, " ");
    var args = line.split(" ");

    var inputPattern = [
      "MM/DD",
      "MM月DD日",
      "YYYY年MM月DD日",
      "YYYY/MM/DD",
      "YYYY-MM-DD"
    ];

    var startTime:moment.Moment = moment.utc(args[1], inputPattern);
    var endTime:moment.Moment | null = null
    if(args[2]){
      endTime = moment.utc(args[2], inputPattern);
    }

    if (args.length > 2) {
      return {
        name: args[0],
        start: startTime.unix() * 1000,
        end: endTime.unix() * 1000 + 1000 * 60 * 60 * 24
      };
    }
    if (args.length === 2){
      return {
        name: args[0],
        start: startTime.unix() * 1000,
        end: null
      };
    }

    return null;
  }).filter(function (item) { return item });
开发者ID:anydown,项目名称:ganttdown,代码行数:37,代码来源:lib.ts


示例7: convertToMoment

function convertToMoment(input: any, timeZone: string, timeZoneOffset: number | null, locale: string): moment.Moment {
  let mom: moment.Moment

  if (timeZone === 'local') {
    mom = moment(input)

  } else if (timeZone === 'UTC') {
    mom = moment.utc(input)

  } else if ((moment as any).tz) {
    mom = (moment as any).tz(input, timeZone)

  } else {
    mom = moment.utc(input)

    if (timeZoneOffset != null) {
      mom.utcOffset(timeZoneOffset)
    }
  }

  mom.locale(locale)

  return mom
}
开发者ID:BorjaPintos,项目名称:fullcalendar,代码行数:24,代码来源:main.ts


示例8: Error

    fn: (_context, args) => {
      const { position, min, max, ...rest } = args;

      if (!Object.values(Position).includes(position)) {
        throw new Error(`Invalid position: '${args.position}'`);
      }

      const minVal = typeof min === 'string' ? moment.utc(min).valueOf() : min;
      const maxVal = typeof max === 'string' ? moment.utc(max).valueOf() : max;

      // This != check is not !== in order to handle NaN cases properly.
      if (minVal != null && isNaN(minVal)) {
        throw new Error(
          `Invalid date string: '${
            args.min
          }'. 'min' must be a number, date in ms, or ISO8601 date string`
        );
      }

      // This != check is not !== in order to handle NaN cases properly.
      if (maxVal != null && isNaN(maxVal)) {
        throw new Error(
          `Invalid date string: '${
            args.max
          }'. 'max' must be a number, date in ms, or ISO8601 date string`
        );
      }

      return {
        max: maxVal,
        min: minVal,
        type: 'axisConfig',
        position,
        ...rest,
      };
    },
开发者ID:elastic,项目名称:kibana,代码行数:36,代码来源:axisConfig.ts


示例9: getIntervalInSeconds

const findLastFullBucket = (
  buckets: InfraSnapshotMetricsBucket[],
  options: InfraSnapshotRequestOptions
) => {
  const to = moment.utc(options.timerange.to);
  const bucketSize = getIntervalInSeconds(options.timerange.interval);
  return buckets.reduce((current, item) => {
    const itemKey = isNumber(item.key) ? item.key : parseInt(item.key, 10);
    const date = moment.utc(itemKey + bucketSize * 1000);
    if (!date.isAfter(to) && item.doc_count > 0) {
      return item;
    }
    return current;
  }, last(buckets));
};
开发者ID:elastic,项目名称:kibana,代码行数:15,代码来源:response_helpers.ts


示例10: beforeEach

    beforeEach(async () => {
      ctx.backendSrv.datasourceRequest = options => {
        if (options.url.indexOf('Microsoft.OperationalInsights/workspaces') > -1) {
          return ctx.$q.when({ data: workspaceResponse, status: 200 });
        } else {
          return ctx.$q.when({ data: tableResponse, status: 200 });
        }
      };

      annotationResults = await ctx.ds.annotationQuery({
        annotation: {
          rawQuery: 'Heartbeat | where $__timeFilter()| project TimeGenerated, Text=Computer, tags="test"',
          workspace: 'abc1b44e-3e57-4410-b027-6cc0ae6dee67',
        },
        range: {
          from: moment.utc('2017-08-22T20:00:00Z'),
          to: moment.utc('2017-08-22T23:59:00Z'),
        },
        rangeRaw: {
          from: 'now-4h',
          to: 'now',
        },
      });
    });
开发者ID:CorpGlory,项目名称:grafana,代码行数:24,代码来源:azure_log_analytics_datasource.test.ts



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
TypeScript moment.weekdays函数代码示例发布时间:2022-05-25
下一篇:
TypeScript moment.updateLocale函数代码示例发布时间:2022-05-25
热门推荐
热门话题
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap