UNPKG

@grafana/ui

Version:
1 lines 1.45 kB
{"version":3,"file":"mapper.mjs","sources":["../../../../../src/components/DateTimePickers/TimeRangePicker/mapper.ts"],"sourcesContent":["import { type TimeOption, type TimeRange, type TimeZone, rangeUtil, dateTimeFormat } from '@grafana/data';\n\n/**\n * Takes a printable TimeOption and builds a TimeRange with DateTime properties from it\n */\nexport const mapOptionToTimeRange = (option: TimeOption, timeZone?: TimeZone): TimeRange => {\n return rangeUtil.convertRawToRange({ from: option.from, to: option.to }, timeZone);\n};\n\n/**\n * Takes a TimeRange and makes a printable TimeOption with formatted date strings correct for the timezone from it\n */\nexport const mapRangeToTimeOption = (range: TimeRange, timeZone?: TimeZone): TimeOption => {\n const from = dateTimeFormat(range.from, { timeZone });\n const to = dateTimeFormat(range.to, { timeZone });\n\n return {\n from,\n to,\n display: `${from} to ${to}`,\n };\n};\n"],"names":[],"mappings":";;;AAKO,MAAM,oBAAA,GAAuB,CAAC,MAAA,EAAoB,QAAA,KAAmC;AAC1F,EAAA,OAAO,SAAA,CAAU,iBAAA,CAAkB,EAAE,IAAA,EAAM,MAAA,CAAO,MAAM,EAAA,EAAI,MAAA,CAAO,EAAA,EAAG,EAAG,QAAQ,CAAA;AACnF;AAKO,MAAM,oBAAA,GAAuB,CAAC,KAAA,EAAkB,QAAA,KAAoC;AACzF,EAAA,MAAM,OAAO,cAAA,CAAe,KAAA,CAAM,IAAA,EAAM,EAAE,UAAU,CAAA;AACpD,EAAA,MAAM,KAAK,cAAA,CAAe,KAAA,CAAM,EAAA,EAAI,EAAE,UAAU,CAAA;AAEhD,EAAA,OAAO;AAAA,IACL,IAAA;AAAA,IACA,EAAA;AAAA,IACA,OAAA,EAAS,CAAA,EAAG,IAAI,CAAA,IAAA,EAAO,EAAE,CAAA;AAAA,GAC3B;AACF;;;;"}