當前位置: 首頁>>代碼示例>>TypeScript>>正文


TypeScript moment_wrapper.isDateTime函數代碼示例

本文整理匯總了TypeScript中@grafana/ui/src/utils/moment_wrapper.isDateTime函數的典型用法代碼示例。如果您正苦於以下問題:TypeScript isDateTime函數的具體用法?TypeScript isDateTime怎麽用?TypeScript isDateTime使用的例子?那麽, 這裏精選的函數代碼示例或許可以為您提供幫助。


在下文中一共展示了isDateTime函數的6個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的TypeScript代碼示例。

示例1: timeRangeForUrl

  timeRangeForUrl() {
    const range = this.timeRange().raw;

    if (isDateTime(range.from)) {
      range.from = range.from.valueOf().toString();
    }
    if (isDateTime(range.to)) {
      range.to = range.to.valueOf().toString();
    }

    return range;
  }
開發者ID:grafana,項目名稱:grafana,代碼行數:12,代碼來源:TimeSrv.ts

示例2: timeRange

  timeRange(): TimeRange {
    // make copies if they are moment  (do not want to return out internal moment, because they are mutable!)
    const raw = {
      from: isDateTime(this.time.from) ? dateTime(this.time.from) : this.time.from,
      to: isDateTime(this.time.to) ? dateTime(this.time.to) : this.time.to,
    };

    const timezone = this.dashboard && this.dashboard.getTimezone();

    return {
      from: dateMath.parse(raw.from, false, timezone),
      to: dateMath.parse(raw.to, true, timezone),
      raw: raw,
    };
  }
開發者ID:grafana,項目名稱:grafana,代碼行數:15,代碼來源:TimeSrv.ts

示例3:

const toRawTimeRange = (range: TimeRange): RawTimeRange => {
  let from = range.raw.from;
  if (isDateTime(from)) {
    from = from.valueOf().toString(10);
  }

  let to = range.raw.to;
  if (isDateTime(to)) {
    to = to.valueOf().toString(10);
  }

  return {
    from,
    to,
  };
};
開發者ID:johntdyer,項目名稱:grafana,代碼行數:16,代碼來源:actions.ts

示例4:

 const toUser = currentValue => {
   if (isDateTime(currentValue)) {
     return currentValue.format(format);
   } else {
     return currentValue;
   }
 };
開發者ID:grafana,項目名稱:grafana,代碼行數:7,代碼來源:validation.ts

示例5: setTime

  setTime(time: RawTimeRange, fromRouteUpdate?: boolean) {
    _.extend(this.time, time);

    // disable refresh if zoom in or zoom out
    if (isDateTime(time.to)) {
      this.oldRefresh = this.dashboard.refresh || this.oldRefresh;
      this.setAutoRefresh(false);
    } else if (this.oldRefresh && this.oldRefresh !== this.dashboard.refresh) {
      this.setAutoRefresh(this.oldRefresh);
      this.oldRefresh = null;
    }

    // update url
    if (fromRouteUpdate !== true) {
      const urlRange = this.timeRangeForUrl();
      const urlParams = this.$location.search();
      urlParams.from = urlRange.from;
      urlParams.to = urlRange.to;
      this.$location.search(urlParams);
    }

    this.$timeout(this.refreshDashboard.bind(this), 0);
  }
開發者ID:grafana,項目名稱:grafana,代碼行數:23,代碼來源:TimeSrv.ts

示例6: it

 it('should return parsed when parse is true', () => {
   timeSrv.setTime({ from: 'now', to: 'now-1h' });
   const time = timeSrv.timeRange();
   expect(isDateTime(time.from)).toBe(true);
   expect(isDateTime(time.to)).toBe(true);
 });
開發者ID:grafana,項目名稱:grafana,代碼行數:6,代碼來源:TimeSrv.test.ts


注:本文中的@grafana/ui/src/utils/moment_wrapper.isDateTime函數示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。