Skip to content

Commit 2d7b440

Browse files
committed
Don't repeat the date when showing a range
1 parent 3505e85 commit 2d7b440

File tree

1 file changed

+14
-10
lines changed

1 file changed

+14
-10
lines changed

apps/webapp/app/components/runs/v3/SharedFilters.tsx

Lines changed: 14 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -246,12 +246,17 @@ export function timeFilterRenderValues({
246246
break;
247247
}
248248
case "range":
249-
valueLabel = (
250-
<span>
251-
<DateTime date={from!} includeTime includeSeconds />{" "}
252-
<DateTime date={to!} includeTime includeSeconds />
253-
</span>
254-
);
249+
{
250+
//If the day is the same, only show the time for the `to` date
251+
const isSameDay = from && to && from.getDate() === to.getDate();
252+
253+
valueLabel = (
254+
<span>
255+
<DateTime date={from!} includeTime includeSeconds />{" "}
256+
<DateTime date={to!} includeTime includeSeconds includeDate={!isSameDay} />
257+
</span>
258+
);
259+
}
255260
break;
256261
case "from":
257262
valueLabel = <DateTime date={from!} includeTime includeSeconds />;
@@ -859,10 +864,9 @@ export function appliedSummary(values: string[], maxValues = 3) {
859864
export function dateFromString(value: string | undefined | null): Date | undefined {
860865
if (!value) return;
861866

862-
//is it an int?
863-
const int = parseInt(value);
864-
if (!isNaN(int)) {
865-
return new Date(int);
867+
// Only treat as timestamp if the string is purely numeric
868+
if (/^\d+$/.test(value)) {
869+
return new Date(parseInt(value));
866870
}
867871

868872
return new Date(value);

0 commit comments

Comments
 (0)