Skip to content

[usage] Use actual date for start time #12123

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Aug 15, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 12 additions & 2 deletions components/dashboard/src/teams/TeamUsage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ import {
} from "@gitpod/gitpod-protocol/lib/usage";
import { AttributionId } from "@gitpod/gitpod-protocol/lib/attribution";
import { Item, ItemField, ItemsList } from "../components/ItemsList";
import moment from "moment";
import Pagination from "../Pagination/Pagination";
import Header from "../components/Header";
import { ErrorCodes } from "@gitpod/gitpod-protocol/lib/messaging/error";
Expand Down Expand Up @@ -139,6 +138,17 @@ function TeamUsage() {
return rows;
};

const displayTime = (time: string) => {
const options: Intl.DateTimeFormatOptions = {
day: "numeric",
month: "long",
year: "numeric",
hour: "numeric",
minute: "numeric",
};
return new Date(time).toLocaleDateString(undefined, options).replace("at ", "");
};

const lastResultOnCurrentPage = currentPage * resultsPerPage;
const firstResultOnCurrentPage = lastResultOnCurrentPage - resultsPerPage;
const totalNumberOfPages = Math.ceil(billedUsage.length / resultsPerPage);
Expand Down Expand Up @@ -250,7 +260,7 @@ function TeamUsage() {
</div>
<div className="my-auto">
<span className="text-gray-400">
{moment(new Date(usage.startTime).toDateString()).fromNow()}
{displayTime(usage.startTime)}
</span>
</div>
</div>
Expand Down