MCPcopy
hub / github.com/deepops-ai/deepops / getSuitableTimeUnit

Function getSuitableTimeUnit

ui/src/utils/date.ts:171–185  ·  view source on GitHub ↗
(microseconds: number)

Source from the content-addressed store, hash-verified

169}
170
171export const getSuitableTimeUnit = (microseconds: number): string => {
172 if (microseconds < 1000) {
173 return 'microseconds';
174 }
175
176 const duration = moment.duration(microseconds / 1000, 'ms');
177
178 return Object.keys(timeUnitToShortTermMapper)
179 .reverse()
180 .find(timeUnit => {
181 const durationInTimeUnit = duration.as(timeUnit as unitOfTime.Base);
182
183 return durationInTimeUnit >= 1;
184 })!;
185};
186
187export function convertTimeUnitToShortTerm(timeUnit: string) {
188 if (timeUnit === 'microseconds') return 'μs';

Callers 1

timeConversionFunction · 0.85

Calls 1

findMethod · 0.80

Tested by

no test coverage detected