diff --git a/packages/react-ui/__tests__/widgets/utils/timeFormat.test.js b/packages/react-ui/__tests__/widgets/utils/timeFormat.test.js index f8d87f369..8390e3e6f 100644 --- a/packages/react-ui/__tests__/widgets/utils/timeFormat.test.js +++ b/packages/react-ui/__tests__/widgets/utils/timeFormat.test.js @@ -19,7 +19,7 @@ describe('timeFormat', () => { stepMultiplier: 1, date: '2022-09-13T13:00:00', stepSize: GroupDateTypes.SECONDS, - expected: '9/13/2022 01:00:00 PM' + expected: '9/13/2022 01:00:00 PM - 01:00:00 PM' }, { title: 'two seconds', diff --git a/packages/react-ui/src/widgets/TimeSeriesWidgetUI/utils/timeFormat.js b/packages/react-ui/src/widgets/TimeSeriesWidgetUI/utils/timeFormat.js index 1c61bfb12..bbcb2b72a 100644 --- a/packages/react-ui/src/widgets/TimeSeriesWidgetUI/utils/timeFormat.js +++ b/packages/react-ui/src/widgets/TimeSeriesWidgetUI/utils/timeFormat.js @@ -27,8 +27,6 @@ export function formatTime({ date, stepSize }) { return formatter(date); } -const SHORTENED_RANGES_WHEN_NO_MULTIPLIES = [GroupDateTypes.SECONDS, GroupDateTypes.DAYS]; - /** * Format time range. * @@ -71,12 +69,16 @@ export function formatBucketRange({ date, stepSize, stepMultiplier }) { const { start, end } = getBucketInterval({ date, stepSize, stepMultiplier }); - if ( - stepMultiplier === 1 && - stepSize && - SHORTENED_RANGES_WHEN_NO_MULTIPLIES.includes(stepSize) - ) { - return formatTime({ date: start, stepSize }); + // exceptions/shorthands + if (stepMultiplier === 1) { + if (stepSize === GroupDateTypes.DAYS) { + return formatTime({ date: start, stepSize }); + } + if (stepSize === GroupDateTypes.SECONDS) { + return `${formatLocalDate(start)} ${formatTimeWithSeconds( + start + )} - ${formatTimeWithSeconds(end)}`; + } } return formatTimeRange({ start, end, stepSize });