diff --git a/portal-ui/package.json b/portal-ui/package.json index a33e05d98..629931175 100644 --- a/portal-ui/package.json +++ b/portal-ui/package.json @@ -29,6 +29,7 @@ "kbar": "^0.1.0-beta.39", "local-storage-fallback": "^4.1.1", "lodash": "^4.17.21", + "luxon": "^3.1.1", "mds": "https://github.com/minio/mds.git#v0.0.8", "minio": "^7.0.32", "moment": "^2.29.4", @@ -73,6 +74,7 @@ }, "proxy": "http://localhost:9090/", "devDependencies": { + "@types/luxon": "^3.1.0", "@types/react-window": "^1.8.5", "@types/react-window-infinite-loader": "^1.0.6", "@types/recharts": "^1.8.24", diff --git a/portal-ui/src/screens/Console/Buckets/ListBuckets/Objects/ListObjects/ListObjects.tsx b/portal-ui/src/screens/Console/Buckets/ListBuckets/Objects/ListObjects/ListObjects.tsx index 03ac45ec8..bef3db9dd 100644 --- a/portal-ui/src/screens/Console/Buckets/ListBuckets/Objects/ListObjects/ListObjects.tsx +++ b/portal-ui/src/screens/Console/Buckets/ListBuckets/Objects/ListObjects/ListObjects.tsx @@ -27,6 +27,7 @@ import { useLocation, useNavigate, useParams } from "react-router-dom"; import { useDropzone } from "react-dropzone"; import { Theme } from "@mui/material/styles"; import { Button } from "mds"; +import { DateTime } from "luxon"; import createStyles from "@mui/styles/createStyles"; import Grid from "@mui/material/Grid"; import get from "lodash/get"; @@ -750,6 +751,12 @@ const ListObjects = () => { dispatch(setDownloadRenameModal(null)); }; + let createdTime = DateTime.now(); + + if (bucketInfo?.creation_date) { + createdTime = DateTime.fromISO(bucketInfo.creation_date); + } + const multiActionButtons = [ { action: () => { @@ -867,9 +874,13 @@ const ListObjects = () => { - Created:    + Created on:   - {new Date(bucketInfo?.creation_date || "").toString()} + {bucketInfo?.creation_date + ? createdTime.toFormat( + "ccc, LLL dd yyyy HH:mm:ss (ZZZZ)" + ) + : ""} diff --git a/portal-ui/src/screens/Console/Buckets/ListBuckets/Objects/ListObjects/ListObjectsHelpers.tsx b/portal-ui/src/screens/Console/Buckets/ListBuckets/Objects/ListObjects/ListObjectsHelpers.tsx index abfaea8b4..511643086 100644 --- a/portal-ui/src/screens/Console/Buckets/ListBuckets/Objects/ListObjects/ListObjectsHelpers.tsx +++ b/portal-ui/src/screens/Console/Buckets/ListBuckets/Objects/ListObjects/ListObjectsHelpers.tsx @@ -14,8 +14,7 @@ // You should have received a copy of the GNU Affero General Public License // along with this program. If not, see . -import React from "react"; -import * as reactMoment from "react-moment"; +import { DateTime } from "luxon"; import { BucketObjectItem } from "./types"; import { niceBytes } from "../../../../../../common/utils"; import { displayFileIconName } from "./utils"; @@ -26,11 +25,20 @@ export const displayParsedDate = (object: BucketObjectItem) => { if (object.name.endsWith("/")) { return ""; } - return ( - - {new Date(object.last_modified).toString()} - - ); + + const currTime = DateTime.now(); + const objectTime = DateTime.fromISO(object.last_modified); + + const isToday = + currTime.hasSame(objectTime, "day") && + currTime.hasSame(objectTime, "month") && + currTime.hasSame(objectTime, "year"); + + if (isToday) { + return `Today, ${objectTime.toFormat("HH:mm")}`; + } + + return objectTime.toFormat("ccc, LLL dd yyyy HH:mm (ZZZZ)"); }; export const displayNiceBytes = (object: BucketObjectItem) => { diff --git a/portal-ui/yarn.lock b/portal-ui/yarn.lock index 55776ae6b..4e66bf0e1 100644 --- a/portal-ui/yarn.lock +++ b/portal-ui/yarn.lock @@ -2367,6 +2367,11 @@ resolved "https://registry.yarnpkg.com/@types/lodash/-/lodash-4.14.184.tgz#23f96cd2a21a28e106dc24d825d4aa966de7a9fe" integrity sha512-RoZphVtHbxPZizt4IcILciSWiC6dcn+eZ8oX9IWEYfDMcocdd42f7NPI6fQj+6zI8y4E0L7gu2pcZKLGTRaV9Q== +"@types/luxon@^3.1.0": + version "3.1.0" + resolved "https://registry.yarnpkg.com/@types/luxon/-/luxon-3.1.0.tgz#b9842d233a06b267fe4117f1c224f20b8a149825" + integrity sha512-gCd/HcCgjqSxfMrgtqxCgYk/22NBQfypwFUG7ZAyG/4pqs51WLTcUzVp1hqTbieDYeHS3WoVEh2Yv/2l+7B0Vg== + "@types/mime@*": version "3.0.1" resolved "https://registry.yarnpkg.com/@types/mime/-/mime-3.0.1.tgz#5f8f2bca0a5863cb69bc0b0acd88c96cb1d4ae10" @@ -8015,6 +8020,11 @@ lru-cache@^6.0.0: dependencies: yallist "^4.0.0" +luxon@^3.1.1: + version "3.1.1" + resolved "https://registry.yarnpkg.com/luxon/-/luxon-3.1.1.tgz#b492c645b2474fb86f3bd3283213846b99c32c1e" + integrity sha512-Ah6DloGmvseB/pX1cAmjbFvyU/pKuwQMQqz7d0yvuDlVYLTs2WeDHQMpC8tGjm1da+BriHROW/OEIT/KfYg6xw== + macos-release@^3.0.1: version "3.1.0" resolved "https://registry.yarnpkg.com/macos-release/-/macos-release-3.1.0.tgz#6165bb0736ae567ed6649e36ce6a24d87cbb7aca"