github.com/grafana/pyroscope@v1.18.0/public/app/components/TimelineChart/getFormatLabel.ts (about) 1 import { getUTCdate, getTimelineFormatDate } from '@pyroscope/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;