本文整理匯總了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;
}
示例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,
};
}
示例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,
};
};
示例4:
const toUser = currentValue => {
if (isDateTime(currentValue)) {
return currentValue.format(format);
} else {
return currentValue;
}
};
示例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);
}
示例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);
});