mirror of
https://github.com/Unleash/unleash.git
synced 2025-01-25 00:07:47 +01:00
refactor: port date utils to TS (#720)
This commit is contained in:
parent
19b16ed600
commit
a4dab966a3
@ -24,7 +24,6 @@ import {
|
|||||||
DELETE_API_TOKEN,
|
DELETE_API_TOKEN,
|
||||||
} from '../../../providers/AccessProvider/permissions';
|
} from '../../../providers/AccessProvider/permissions';
|
||||||
import { useStyles } from './ApiTokenList.styles';
|
import { useStyles } from './ApiTokenList.styles';
|
||||||
import { formatDateWithLocale } from '../../../common/util';
|
|
||||||
import Secret from './secret';
|
import Secret from './secret';
|
||||||
import { Delete, FileCopy } from '@material-ui/icons';
|
import { Delete, FileCopy } from '@material-ui/icons';
|
||||||
import Dialogue from '../../../common/Dialogue';
|
import Dialogue from '../../../common/Dialogue';
|
||||||
@ -32,6 +31,7 @@ import { CREATE_API_TOKEN_BUTTON } from '../../../../testIds';
|
|||||||
import { Alert } from '@material-ui/lab';
|
import { Alert } from '@material-ui/lab';
|
||||||
import copy from 'copy-to-clipboard';
|
import copy from 'copy-to-clipboard';
|
||||||
import { useLocationSettings } from '../../../../hooks/useLocationSettings';
|
import { useLocationSettings } from '../../../../hooks/useLocationSettings';
|
||||||
|
import { formatDateYMD } from '../../../../utils/format-date';
|
||||||
|
|
||||||
interface IApiToken {
|
interface IApiToken {
|
||||||
createdAt: Date;
|
createdAt: Date;
|
||||||
@ -146,7 +146,7 @@ export const ApiTokenList = () => {
|
|||||||
align="left"
|
align="left"
|
||||||
className={styles.hideSM}
|
className={styles.hideSM}
|
||||||
>
|
>
|
||||||
{formatDateWithLocale(
|
{formatDateYMD(
|
||||||
item.createdAt,
|
item.createdAt,
|
||||||
locationSettings.locale
|
locationSettings.locale
|
||||||
)}
|
)}
|
||||||
|
@ -8,7 +8,6 @@ import {
|
|||||||
Button,
|
Button,
|
||||||
} from '@material-ui/core';
|
} from '@material-ui/core';
|
||||||
import OpenInNew from '@material-ui/icons/OpenInNew';
|
import OpenInNew from '@material-ui/icons/OpenInNew';
|
||||||
import { formatDateWithLocale } from '../../common/util';
|
|
||||||
import PageContent from '../../common/PageContent';
|
import PageContent from '../../common/PageContent';
|
||||||
import HeaderTitle from '../../common/HeaderTitle';
|
import HeaderTitle from '../../common/HeaderTitle';
|
||||||
import ConditionallyRender from '../../common/ConditionallyRender';
|
import ConditionallyRender from '../../common/ConditionallyRender';
|
||||||
@ -16,6 +15,7 @@ import { formatApiPath } from '../../../utils/format-path';
|
|||||||
import useInvoices from '../../../hooks/api/getters/useInvoices/useInvoices';
|
import useInvoices from '../../../hooks/api/getters/useInvoices/useInvoices';
|
||||||
import { IInvoice } from '../../../interfaces/invoice';
|
import { IInvoice } from '../../../interfaces/invoice';
|
||||||
import { useLocationSettings } from '../../../hooks/useLocationSettings';
|
import { useLocationSettings } from '../../../hooks/useLocationSettings';
|
||||||
|
import { formatDateYMD } from '../../../utils/format-date';
|
||||||
|
|
||||||
const PORTAL_URL = formatApiPath('api/admin/invoices/portal');
|
const PORTAL_URL = formatApiPath('api/admin/invoices/portal');
|
||||||
|
|
||||||
@ -87,7 +87,7 @@ const InvoiceList = () => {
|
|||||||
style={{ textAlign: 'left' }}
|
style={{ textAlign: 'left' }}
|
||||||
>
|
>
|
||||||
{item.dueDate &&
|
{item.dueDate &&
|
||||||
formatDateWithLocale(
|
formatDateYMD(
|
||||||
item.dueDate,
|
item.dueDate,
|
||||||
locationSettings.locale
|
locationSettings.locale
|
||||||
)}
|
)}
|
||||||
|
@ -1,20 +1,20 @@
|
|||||||
import {
|
import {
|
||||||
TableRow,
|
|
||||||
TableCell,
|
|
||||||
Avatar,
|
Avatar,
|
||||||
IconButton,
|
IconButton,
|
||||||
|
TableCell,
|
||||||
|
TableRow,
|
||||||
Typography,
|
Typography,
|
||||||
} from '@material-ui/core';
|
} from '@material-ui/core';
|
||||||
import { Edit, Lock, Delete } from '@material-ui/icons';
|
import { Delete, Edit, Lock } from '@material-ui/icons';
|
||||||
import { SyntheticEvent, useContext } from 'react';
|
import { SyntheticEvent, useContext } from 'react';
|
||||||
import { ADMIN } from '../../../../providers/AccessProvider/permissions';
|
import { ADMIN } from '../../../../providers/AccessProvider/permissions';
|
||||||
import ConditionallyRender from '../../../../common/ConditionallyRender';
|
import ConditionallyRender from '../../../../common/ConditionallyRender';
|
||||||
import { formatDateWithLocale } from '../../../../common/util';
|
|
||||||
import AccessContext from '../../../../../contexts/AccessContext';
|
import AccessContext from '../../../../../contexts/AccessContext';
|
||||||
import { IUser } from '../../../../../interfaces/user';
|
import { IUser } from '../../../../../interfaces/user';
|
||||||
import { useStyles } from './UserListItem.styles';
|
import { useStyles } from './UserListItem.styles';
|
||||||
import { useHistory } from 'react-router-dom';
|
import { useHistory } from 'react-router-dom';
|
||||||
import { ILocationSettings } from '../../../../../hooks/useLocationSettings';
|
import { ILocationSettings } from '../../../../../hooks/useLocationSettings';
|
||||||
|
import { formatDateYMD } from '../../../../../utils/format-date';
|
||||||
|
|
||||||
interface IUserListItemProps {
|
interface IUserListItemProps {
|
||||||
user: IUser;
|
user: IUser;
|
||||||
@ -51,10 +51,7 @@ const UserListItem = ({
|
|||||||
</TableCell>
|
</TableCell>
|
||||||
<TableCell>
|
<TableCell>
|
||||||
<span data-loading>
|
<span data-loading>
|
||||||
{formatDateWithLocale(
|
{formatDateYMD(user.createdAt, locationSettings.locale)}
|
||||||
user.createdAt,
|
|
||||||
locationSettings.locale
|
|
||||||
)}
|
|
||||||
</span>
|
</span>
|
||||||
</TableCell>
|
</TableCell>
|
||||||
<TableCell className={styles.leftTableCell}>
|
<TableCell className={styles.leftTableCell}>
|
||||||
|
@ -10,7 +10,6 @@ import {
|
|||||||
} from '@material-ui/core';
|
} from '@material-ui/core';
|
||||||
import { Link as LinkIcon } from '@material-ui/icons';
|
import { Link as LinkIcon } from '@material-ui/icons';
|
||||||
import ConditionallyRender from '../../common/ConditionallyRender/ConditionallyRender';
|
import ConditionallyRender from '../../common/ConditionallyRender/ConditionallyRender';
|
||||||
import { formatDateWithLocale } from '../../common/util';
|
|
||||||
import { UPDATE_APPLICATION } from '../../providers/AccessProvider/permissions';
|
import { UPDATE_APPLICATION } from '../../providers/AccessProvider/permissions';
|
||||||
import { ApplicationView } from '../ApplicationView/ApplicationView';
|
import { ApplicationView } from '../ApplicationView/ApplicationView';
|
||||||
import { ApplicationUpdate } from '../ApplicationUpdate/ApplicationUpdate';
|
import { ApplicationUpdate } from '../ApplicationUpdate/ApplicationUpdate';
|
||||||
@ -25,6 +24,7 @@ import { useHistory, useParams } from 'react-router-dom';
|
|||||||
import { useLocationSettings } from '../../../hooks/useLocationSettings';
|
import { useLocationSettings } from '../../../hooks/useLocationSettings';
|
||||||
import useToast from '../../../hooks/useToast';
|
import useToast from '../../../hooks/useToast';
|
||||||
import PermissionButton from '../../common/PermissionButton/PermissionButton';
|
import PermissionButton from '../../common/PermissionButton/PermissionButton';
|
||||||
|
import { formatDateYMD } from '../../../utils/format-date';
|
||||||
|
|
||||||
export const ApplicationEdit = () => {
|
export const ApplicationEdit = () => {
|
||||||
const history = useHistory();
|
const history = useHistory();
|
||||||
@ -42,8 +42,7 @@ export const ApplicationEdit = () => {
|
|||||||
setShowDialog(!showDialog);
|
setShowDialog(!showDialog);
|
||||||
};
|
};
|
||||||
|
|
||||||
const formatDate = (v: string) =>
|
const formatDate = (v: string) => formatDateYMD(v, locationSettings.locale);
|
||||||
formatDateWithLocale(v, locationSettings.locale);
|
|
||||||
|
|
||||||
const onDeleteApplication = async (evt: Event) => {
|
const onDeleteApplication = async (evt: Event) => {
|
||||||
evt.preventDefault();
|
evt.preventDefault();
|
||||||
|
@ -23,13 +23,16 @@ import ConditionallyRender from '../../common/ConditionallyRender/ConditionallyR
|
|||||||
import { getTogglePath } from '../../../utils/route-path-helpers';
|
import { getTogglePath } from '../../../utils/route-path-helpers';
|
||||||
import useApplication from '../../../hooks/api/getters/useApplication/useApplication';
|
import useApplication from '../../../hooks/api/getters/useApplication/useApplication';
|
||||||
import AccessContext from '../../../contexts/AccessContext';
|
import AccessContext from '../../../contexts/AccessContext';
|
||||||
import { formatFullDateTimeWithLocale } from '../../common/util';
|
import { formatDateYMDHMS } from '../../../utils/format-date';
|
||||||
|
import { useLocationSettings } from '../../../hooks/useLocationSettings';
|
||||||
|
|
||||||
export const ApplicationView = () => {
|
export const ApplicationView = () => {
|
||||||
const { hasAccess } = useContext(AccessContext);
|
const { hasAccess } = useContext(AccessContext);
|
||||||
const { name } = useParams<{ name: string }>();
|
const { name } = useParams<{ name: string }>();
|
||||||
const { application } = useApplication(name);
|
const { application } = useApplication(name);
|
||||||
|
const { locationSettings } = useLocationSettings();
|
||||||
const { instances, strategies, seenToggles } = application;
|
const { instances, strategies, seenToggles } = application;
|
||||||
|
|
||||||
const notFoundListItem = ({
|
const notFoundListItem = ({
|
||||||
createUrl,
|
createUrl,
|
||||||
name,
|
name,
|
||||||
@ -195,8 +198,9 @@ export const ApplicationView = () => {
|
|||||||
<span>
|
<span>
|
||||||
{clientIp} last seen at{' '}
|
{clientIp} last seen at{' '}
|
||||||
<small>
|
<small>
|
||||||
{formatFullDateTimeWithLocale(
|
{formatDateYMDHMS(
|
||||||
lastSeen
|
lastSeen,
|
||||||
|
locationSettings.locale
|
||||||
)}
|
)}
|
||||||
</small>
|
</small>
|
||||||
</span>
|
</span>
|
||||||
|
@ -1,35 +0,0 @@
|
|||||||
import { formatFullDateTimeWithLocale } from '../util';
|
|
||||||
|
|
||||||
test.skip('formats dates correctly', () => {
|
|
||||||
expect(formatFullDateTimeWithLocale(1487861809466, 'nb-NO', 'UTC')).toEqual(
|
|
||||||
'2017-02-23 14:56:49'
|
|
||||||
);
|
|
||||||
expect(
|
|
||||||
formatFullDateTimeWithLocale(1487861809466, 'nb-NO', 'Europe/Paris')
|
|
||||||
).toEqual('2017-02-23 15:56:49');
|
|
||||||
expect(
|
|
||||||
formatFullDateTimeWithLocale(1487861809466, 'nb-NO', 'Europe/Oslo')
|
|
||||||
).toEqual('2017-02-23 15:56:49');
|
|
||||||
expect(
|
|
||||||
formatFullDateTimeWithLocale(1487861809466, 'nb-NO', 'Europe/London')
|
|
||||||
).toEqual('2017-02-23 14:56:49');
|
|
||||||
expect(
|
|
||||||
formatFullDateTimeWithLocale(1487861809466, 'en-GB', 'Europe/Paris')
|
|
||||||
).toEqual('02/23/2017, 3:56:49 PM');
|
|
||||||
expect(
|
|
||||||
formatFullDateTimeWithLocale(1487861809466, 'en-GB', 'Europe/Oslo')
|
|
||||||
).toEqual('02/23/2017, 3:56:49 PM');
|
|
||||||
expect(
|
|
||||||
formatFullDateTimeWithLocale(1487861809466, 'en-GB', 'Europe/London')
|
|
||||||
).toEqual('02/23/2017, 2:56:49 PM');
|
|
||||||
|
|
||||||
expect(formatFullDateTimeWithLocale(1487861809466, 'nb-NO')).toEqual(
|
|
||||||
expect.stringMatching(/(\d{4}-\d{2}-\d{2} \d{2}:\d{2}:\d{2})/)
|
|
||||||
);
|
|
||||||
expect(formatFullDateTimeWithLocale(1487861809466, 'en-GB')).toEqual(
|
|
||||||
expect.stringContaining('02/23/2017')
|
|
||||||
);
|
|
||||||
expect(formatFullDateTimeWithLocale(1487861809466, 'en-US')).toEqual(
|
|
||||||
expect.stringContaining('02/23/2017')
|
|
||||||
);
|
|
||||||
});
|
|
@ -1,26 +1,6 @@
|
|||||||
import { weightTypes } from '../feature/FeatureView/FeatureVariants/FeatureVariantsList/AddFeatureVariant/enums';
|
import { weightTypes } from '../feature/FeatureView/FeatureVariants/FeatureVariantsList/AddFeatureVariant/enums';
|
||||||
import differenceInDays from 'date-fns/differenceInDays';
|
import differenceInDays from 'date-fns/differenceInDays';
|
||||||
|
|
||||||
const dateTimeOptions = {
|
|
||||||
day: '2-digit',
|
|
||||||
month: '2-digit',
|
|
||||||
year: 'numeric',
|
|
||||||
hour: '2-digit',
|
|
||||||
minute: '2-digit',
|
|
||||||
second: '2-digit',
|
|
||||||
};
|
|
||||||
|
|
||||||
const dateOptions = {
|
|
||||||
day: '2-digit',
|
|
||||||
month: '2-digit',
|
|
||||||
year: 'numeric',
|
|
||||||
};
|
|
||||||
|
|
||||||
const timeOptions = {
|
|
||||||
hour: '2-digit',
|
|
||||||
minute: '2-digit',
|
|
||||||
};
|
|
||||||
|
|
||||||
export const filterByFlags = flags => r => {
|
export const filterByFlags = flags => r => {
|
||||||
if (r.flag && !flags[r.flag]) {
|
if (r.flag && !flags[r.flag]) {
|
||||||
return false;
|
return false;
|
||||||
@ -32,27 +12,6 @@ export const scrollToTop = () => {
|
|||||||
window.scrollTo(0, 0);
|
window.scrollTo(0, 0);
|
||||||
};
|
};
|
||||||
|
|
||||||
export const formatFullDateTimeWithLocale = (v, locale, tz) => {
|
|
||||||
if (tz) {
|
|
||||||
dateTimeOptions.timeZone = tz;
|
|
||||||
}
|
|
||||||
return new Date(v).toLocaleString(locale, dateTimeOptions);
|
|
||||||
};
|
|
||||||
|
|
||||||
export const formatDateWithLocale = (v, locale, tz) => {
|
|
||||||
if (tz) {
|
|
||||||
dateTimeOptions.timeZone = tz;
|
|
||||||
}
|
|
||||||
return new Date(v).toLocaleString(locale, dateOptions);
|
|
||||||
};
|
|
||||||
|
|
||||||
export const formatTimeWithLocale = (v, locale, tz) => {
|
|
||||||
if (tz) {
|
|
||||||
dateTimeOptions.timeZone = tz;
|
|
||||||
}
|
|
||||||
return new Date(v).toLocaleString(locale, timeOptions);
|
|
||||||
};
|
|
||||||
|
|
||||||
export const trim = value => {
|
export const trim = value => {
|
||||||
if (value && value.trim) {
|
if (value && value.trim) {
|
||||||
return value.trim();
|
return value.trim();
|
||||||
|
@ -1,9 +1,6 @@
|
|||||||
import { Tooltip } from '@material-ui/core';
|
import { Tooltip } from '@material-ui/core';
|
||||||
import {
|
|
||||||
formatDateWithLocale,
|
|
||||||
formatFullDateTimeWithLocale,
|
|
||||||
} from '../../../common/util';
|
|
||||||
import { useLocationSettings } from '../../../../hooks/useLocationSettings';
|
import { useLocationSettings } from '../../../../hooks/useLocationSettings';
|
||||||
|
import { formatDateYMD, formatDateYMDHMS } from '../../../../utils/format-date';
|
||||||
|
|
||||||
interface CreatedAtProps {
|
interface CreatedAtProps {
|
||||||
time: Date;
|
time: Date;
|
||||||
@ -14,12 +11,12 @@ const CreatedAt = ({ time }: CreatedAtProps) => {
|
|||||||
|
|
||||||
return (
|
return (
|
||||||
<Tooltip
|
<Tooltip
|
||||||
title={`Created at ${formatFullDateTimeWithLocale(
|
title={`Created at ${formatDateYMDHMS(
|
||||||
time,
|
time,
|
||||||
locationSettings.locale
|
locationSettings.locale
|
||||||
)}`}
|
)}`}
|
||||||
>
|
>
|
||||||
<span>{formatDateWithLocale(time, locationSettings.locale)}</span>
|
<span>{formatDateYMD(time, locationSettings.locale)}</span>
|
||||||
</Tooltip>
|
</Tooltip>
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
@ -1,9 +1,9 @@
|
|||||||
import { ILocationSettings } from '../../../../../hooks/useLocationSettings';
|
import { ILocationSettings } from '../../../../../hooks/useLocationSettings';
|
||||||
import 'chartjs-adapter-date-fns';
|
import 'chartjs-adapter-date-fns';
|
||||||
import { ChartOptions, defaults } from 'chart.js';
|
import { ChartOptions, defaults } from 'chart.js';
|
||||||
import { formatTimeWithLocale } from '../../../../common/util';
|
|
||||||
import { IFeatureMetricsRaw } from '../../../../../interfaces/featureToggle';
|
import { IFeatureMetricsRaw } from '../../../../../interfaces/featureToggle';
|
||||||
import theme from '../../../../../themes/main-theme';
|
import theme from '../../../../../themes/main-theme';
|
||||||
|
import { formatDateHM } from '../../../../../utils/format-date';
|
||||||
|
|
||||||
export const createChartOptions = (
|
export const createChartOptions = (
|
||||||
metrics: IFeatureMetricsRaw[],
|
metrics: IFeatureMetricsRaw[],
|
||||||
@ -30,7 +30,7 @@ export const createChartOptions = (
|
|||||||
usePointStyle: true,
|
usePointStyle: true,
|
||||||
callbacks: {
|
callbacks: {
|
||||||
title: items =>
|
title: items =>
|
||||||
formatTimeWithLocale(
|
formatDateHM(
|
||||||
items[0].parsed.x,
|
items[0].parsed.x,
|
||||||
locationSettings.locale
|
locationSettings.locale
|
||||||
),
|
),
|
||||||
@ -73,10 +73,7 @@ export const createChartOptions = (
|
|||||||
grid: { display: false },
|
grid: { display: false },
|
||||||
ticks: {
|
ticks: {
|
||||||
callback: (_, i, data) =>
|
callback: (_, i, data) =>
|
||||||
formatTimeWithLocale(
|
formatDateHM(data[i].value, locationSettings.locale),
|
||||||
data[i].value,
|
|
||||||
locationSettings.locale
|
|
||||||
),
|
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
@ -9,8 +9,8 @@ import {
|
|||||||
useTheme,
|
useTheme,
|
||||||
} from '@material-ui/core';
|
} from '@material-ui/core';
|
||||||
import { useLocationSettings } from '../../../../../hooks/useLocationSettings';
|
import { useLocationSettings } from '../../../../../hooks/useLocationSettings';
|
||||||
import { formatFullDateTimeWithLocale } from '../../../../common/util';
|
|
||||||
import { useMemo } from 'react';
|
import { useMemo } from 'react';
|
||||||
|
import { formatDateYMDHMS } from 'utils/format-date';
|
||||||
|
|
||||||
export const FEATURE_METRICS_TABLE_ID = 'feature-metrics-table-id';
|
export const FEATURE_METRICS_TABLE_ID = 'feature-metrics-table-id';
|
||||||
|
|
||||||
@ -48,7 +48,7 @@ export const FeatureMetricsTable = ({ metrics }: IFeatureMetricsTableProps) => {
|
|||||||
{sortedMetrics.map(metric => (
|
{sortedMetrics.map(metric => (
|
||||||
<TableRow key={metric.timestamp}>
|
<TableRow key={metric.timestamp}>
|
||||||
<TableCell>
|
<TableCell>
|
||||||
{formatFullDateTimeWithLocale(
|
{formatDateYMDHMS(
|
||||||
metric.timestamp,
|
metric.timestamp,
|
||||||
locationSettings.locale
|
locationSettings.locale
|
||||||
)}
|
)}
|
||||||
|
@ -1,14 +1,11 @@
|
|||||||
import { List, Switch, FormControlLabel } from '@material-ui/core';
|
import { List, Switch, FormControlLabel } from '@material-ui/core';
|
||||||
import PropTypes from 'prop-types';
|
import PropTypes from 'prop-types';
|
||||||
|
|
||||||
import { formatFullDateTimeWithLocale } from '../../common/util';
|
|
||||||
|
|
||||||
import EventJson from './EventJson/EventJson';
|
import EventJson from './EventJson/EventJson';
|
||||||
import PageContent from '../../common/PageContent/PageContent';
|
import PageContent from '../../common/PageContent/PageContent';
|
||||||
import HeaderTitle from '../../common/HeaderTitle';
|
import HeaderTitle from '../../common/HeaderTitle';
|
||||||
import EventCard from './EventCard/EventCard';
|
import EventCard from './EventCard/EventCard';
|
||||||
|
|
||||||
import { useStyles } from './EventLog.styles.js';
|
import { useStyles } from './EventLog.styles.js';
|
||||||
|
import { formatDateYMDHMS } from '../../../utils/format-date';
|
||||||
|
|
||||||
const EventLog = ({
|
const EventLog = ({
|
||||||
title,
|
title,
|
||||||
@ -23,7 +20,7 @@ const EventLog = ({
|
|||||||
setEventSettings({ showData: !eventSettings.showData });
|
setEventSettings({ showData: !eventSettings.showData });
|
||||||
};
|
};
|
||||||
const formatFulldateTime = v => {
|
const formatFulldateTime = v => {
|
||||||
return formatFullDateTimeWithLocale(v, locationSettings.locale);
|
return formatDateYMDHMS(v, locationSettings.locale);
|
||||||
};
|
};
|
||||||
|
|
||||||
if (!history || history.length < 0) {
|
if (!history || history.length < 0) {
|
||||||
|
34
frontend/src/utils/format-date.ts
Normal file
34
frontend/src/utils/format-date.ts
Normal file
@ -0,0 +1,34 @@
|
|||||||
|
export const formatDateYMDHMS = (
|
||||||
|
date: number | string | Date,
|
||||||
|
locale: string
|
||||||
|
): string => {
|
||||||
|
return new Date(date).toLocaleString(locale, {
|
||||||
|
day: '2-digit',
|
||||||
|
month: '2-digit',
|
||||||
|
year: 'numeric',
|
||||||
|
hour: '2-digit',
|
||||||
|
minute: '2-digit',
|
||||||
|
second: '2-digit',
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
|
export const formatDateYMD = (
|
||||||
|
date: number | string | Date,
|
||||||
|
locale: string
|
||||||
|
): string => {
|
||||||
|
return new Date(date).toLocaleString(locale, {
|
||||||
|
day: '2-digit',
|
||||||
|
month: '2-digit',
|
||||||
|
year: 'numeric',
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
|
export const formatDateHM = (
|
||||||
|
date: number | string | Date,
|
||||||
|
locale: string
|
||||||
|
): string => {
|
||||||
|
return new Date(date).toLocaleString(locale, {
|
||||||
|
hour: '2-digit',
|
||||||
|
minute: '2-digit',
|
||||||
|
});
|
||||||
|
};
|
Loading…
Reference in New Issue
Block a user