1import { Field } from '../types/dataFrame'; 2 3/** 4 * Returns minimal time step from series time field 5 * @param timeField 6 */ 7export const getSeriesTimeStep = (timeField: Field): number => { 8 let previousTime: number | undefined; 9 let minTimeStep: number | undefined; 10 let returnTimeStep = Number.MAX_VALUE; 11 12 for (let i = 0; i < timeField.values.length; i++) { 13 const currentTime = timeField.values.get(i); 14 15 if (previousTime !== undefined) { 16 const timeStep = currentTime - previousTime; 17 18 if (minTimeStep === undefined) { 19 returnTimeStep = timeStep; 20 } 21 22 if (timeStep < returnTimeStep) { 23 returnTimeStep = timeStep; 24 } 25 } 26 previousTime = currentTime; 27 } 28 return returnTimeStep; 29}; 30 31/** 32 * Checks if series time field has ms resolution 33 * @param timeField 34 */ 35export const hasMsResolution = (timeField: Field) => { 36 for (let i = 0; i < timeField.values.length; i++) { 37 const value = timeField.values.get(i); 38 if (value !== null && value !== undefined) { 39 const timestamp = value.toString(); 40 if (timestamp.length === 13 && timestamp % 1000 !== 0) { 41 return true; 42 } 43 } 44 } 45 return false; 46}; 47