ImagesTable: show detailed time when hovering over the "Updated" column

This commit is contained in:
Florian Schüller 2024-04-29 19:50:24 +02:00 committed by Klara Simickova
parent baf58829eb
commit c1d6053083
2 changed files with 27 additions and 1 deletions

View file

@ -66,6 +66,7 @@ import { resolveRelPath } from '../../Utilities/path';
import {
computeHoursToExpiration,
timestampToDisplayString,
timestampToDisplayStringDetailed,
} from '../../Utilities/time';
import { useExperimentalFlag } from '../../Utilities/useExperimentalFlag';
@ -469,7 +470,10 @@ const Row = ({
}}
/>
<Td dataLabel="Image name">{compose.image_name || compose.id}</Td>
<Td dataLabel="Created">
<Td
dataLabel="Created"
title={timestampToDisplayStringDetailed(compose.created_at)}
>
{timestampToDisplayString(compose.created_at)}
</Td>
<Td dataLabel="Release">

View file

@ -57,6 +57,28 @@ export const timestampToDisplayString = (ts?: string) => {
return tsDisplay;
};
export const timestampToDisplayStringDetailed = (ts?: string) => {
// Detailed representation including time and time zone
if (!ts) {
return '';
}
const ms = Date.parse(ts);
const options: Intl.DateTimeFormatOptions = {
year: 'numeric',
month: 'short',
day: 'numeric',
hour: 'numeric',
minute: 'numeric',
second: 'numeric',
hour12: false,
timeZoneName: 'short',
};
const tsDisplay = new Intl.DateTimeFormat('en-US', options).format(ms);
return tsDisplay;
};
export const convertStringToDate = (createdAtAsString: string = '') => {
if (isNaN(Date.parse(createdAtAsString))) {
// converts property created_at of the image object from string to UTC