Skip to content

Commit

Permalink
switch from .tolocaleString() to day.js
Browse files Browse the repository at this point in the history
  • Loading branch information
madejackson committed Sep 23, 2024
1 parent a4423e9 commit a6cb93f
Show file tree
Hide file tree
Showing 5 changed files with 11 additions and 7 deletions.
5 changes: 3 additions & 2 deletions client/src/pages/config/users/usermanagement.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ import MainCard from '../../../components/MainCard';
import { useEffect, useState } from 'react';
import PrettyTableView from '../../../components/tableView/prettyTableView';
import { Trans, useTranslation } from 'react-i18next';
import dayjs from 'dayjs';

const UserManagement = () => {
const { t } = useTranslation();
Expand Down Expand Up @@ -248,14 +249,14 @@ const UserManagement = () => {
{
title: t('global.createdAt'),
screenMin: 'lg',
field: (r) => new Date(r.createdAt).toLocaleString(),
field: (r) => dayjs(new Date(r.createdAt)).format('L, LT'),
},
{
title: t('mgmt.usermgmt.lastLogin'),
screenMin: 'lg',
field: (r) => {
const hasLastLogin = new Date(r.lastLogin).getTime() > 0;
return <>{hasLastLogin ? new Date(r.lastLogin).toLocaleString() : t('global.never')}</>
return <>{hasLastLogin ? dayjs(new Date(r.lastLogin)).format('L, LT') : t('global.never')}</>
},
},
{
Expand Down
3 changes: 2 additions & 1 deletion client/src/pages/dashboard/AlertPage.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ import { DeleteButton } from '../../components/delete';
import { CosmosCheckbox, CosmosFormDivider, CosmosInputText, CosmosSelect } from '../config/users/formShortcuts';
import { MetricPicker } from './MetricsPicker';
import { useTranslation } from 'react-i18next';
import dayjs from 'dayjs';

const DisplayOperator = (operator) => {
switch (operator) {
Expand Down Expand Up @@ -482,7 +483,7 @@ const AlertPage = () => {
{
title: t('navigation.monitoring.alerts.astTriggeredTitle'),
screenMin: 'md',
field: (r) => (r.LastTriggered != "0001-01-01T00:00:00Z") ? new Date(r.LastTriggered).toLocaleString() : t('global.never'),
field: (r) => (r.LastTriggered != "0001-01-01T00:00:00Z") ? dayjs(new Date(r.LastTriggered)).format('L, LT') : t('global.never'),
},
{
title: t('navigation.monitoring.alerts.actionsTitle'),
Expand Down
4 changes: 2 additions & 2 deletions client/src/pages/dashboard/eventsExplorer.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,7 @@ const EventsExplorer = ({from, to, xAxis, zoom, slot, initLevel, initSearch = ''
</Stack>
<div>
{!loading &&
<Trans i18nKey="navigation.monitoring.events.eventsFound" count={total} values={{from: from.toLocaleString(), to: to.toLocaleString()}}/>
<Trans i18nKey="navigation.monitoring.events.eventsFound" count={total} values={{from: dayjs(from).format('L, LT'), to: dayjs(to).format('L, LT')}}/>
}
</div>
<div>
Expand All @@ -172,7 +172,7 @@ const EventsExplorer = ({from, to, xAxis, zoom, slot, initLevel, initSearch = ''
event.level == "debug" ? <SettingOutlined /> : event.level == "important" ? <ExclamationOutlined /> : undefined
}>
<div style={{fontWeight: 'bold', fontSize: '120%'}}>{event.label}</div>
<div>{(new Date(event.date)).toLocaleString()} - {dayjs(event.date).fromNow()}</div>
<div>{dayjs(event.date).format('L, LT')} - {dayjs(event.date).fromNow()}</div>
<div>{event.eventId} - {event.object}</div>
</Alert>}>
<div style={{overflow: 'auto'}}>
Expand Down
3 changes: 2 additions & 1 deletion client/src/pages/servapps/networks.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import * as API from '../../api';
import PrettyTableView from '../../components/tableView/prettyTableView';
import NewNetworkButton from './createNetwork';
import { useTranslation } from 'react-i18next';
import dayjs from 'dayjs';

export const NetworksColumns = (theme, isDark, t) => [
{
Expand Down Expand Up @@ -42,7 +43,7 @@ export const NetworksColumns = (theme, isDark, t) => [
{
title: t('global.createdAt'),
screenMin: 'lg',
field: (r) => r.Created ? new Date(r.Created).toLocaleString() : '-',
field: (r) => r.Created ? dayjs(new Date(r.Created)).format('L, LT') : '-',
},
];

Expand Down
3 changes: 2 additions & 1 deletion client/src/pages/servapps/volumes.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ import HostChip from '../../components/hostChip';
import PrettyTableView from '../../components/tableView/prettyTableView';
import NewVolumeButton from './createVolumes';
import { useTranslation } from 'react-i18next';
import dayjs from 'dayjs';

const VolumeManagementList = () => {
const { t } = useTranslation();
Expand Down Expand Up @@ -76,7 +77,7 @@ const VolumeManagementList = () => {
{
title: t('global.createdAt'),
screenMin: 'lg',
field: (r) => new Date(r.CreatedAt).toLocaleString(),
field: (r) => dayjs(new Date(r.CreatedAt)).format('L, LT'),
},
{
title: '',
Expand Down

0 comments on commit a6cb93f

Please sign in to comment.