github.com/pyroscope-io/pyroscope@v0.37.3-0.20230725203016-5f6947968bd0/webapp/javascript/components/TimelineChart/SyncTimelines/getSelectionBoundaries.ts (about) 1 import { formatAsOBject } from '@webapp/util/formatDate'; 2 import { Selection } from '../markings'; 3 4 export const getSelectionBoundaries = (selection: Selection) => { 5 if (selection.from.startsWith('now') || selection.to.startsWith('now')) { 6 return { 7 from: new Date(formatAsOBject(selection.from)).getTime(), 8 to: new Date(formatAsOBject(selection.to)).getTime(), 9 }; 10 } 11 12 return { 13 from: 14 selection.from.length === 10 15 ? Number(selection.from) * 1000 16 : Number(selection.from), 17 to: 18 selection.to.length === 10 19 ? Number(selection.to) * 1000 20 : Number(selection.to), 21 }; 22 };