@grafana/ui
Version:
Grafana Components Library
25 lines (22 loc) • 858 B
JavaScript
import { rangeUtil, dateTimeFormat } from '@grafana/data';
import { getFeatureToggle } from '../../../utils/featureToggle.mjs';
import { commonFormat } from '../commonFormat.mjs';
;
const mapOptionToTimeRange = (option, timeZone) => {
return rangeUtil.convertRawToRange({ from: option.from, to: option.to }, timeZone, void 0, commonFormat);
};
const mapRangeToTimeOption = (range, timeZone) => {
const from = dateTimeFormat(range.from, { timeZone, format: commonFormat });
const to = dateTimeFormat(range.to, { timeZone, format: commonFormat });
let display = `${from} to ${to}`;
if (getFeatureToggle("localeFormatPreference")) {
display = rangeUtil.describeTimeRange(range, timeZone);
}
return {
from,
to,
display
};
};
export { mapOptionToTimeRange, mapRangeToTimeOption };
//# sourceMappingURL=mapper.mjs.map