github.com/pyroscope-io/pyroscope@v0.37.3-0.20230725203016-5f6947968bd0/webapp/javascript/components/TimelineChart/getFormatLabel.ts (about) 1 import { getUTCdate, getTimelineFormatDate } from '@webapp/util/formatDate'; 2 3 function getFormatLabel({ 4 date, 5 timezone, 6 xaxis, 7 }: { 8 date: number; 9 timezone?: string; 10 xaxis: { 11 min: number; 12 max: number; 13 }; 14 }) { 15 if (!xaxis) { 16 return ''; 17 } 18 19 try { 20 const d = getUTCdate( 21 new Date(date), 22 timezone === 'utc' ? 0 : new Date().getTimezoneOffset() 23 ); 24 25 const hours = Math.abs(xaxis.max - xaxis.min) / 60 / 60 / 1000; 26 27 return getTimelineFormatDate(d, hours); 28 } catch (e) { 29 return '???'; 30 } 31 } 32 33 export default getFormatLabel;