1
0
mirror of https://github.com/Unleash/unleash.git synced 2025-10-09 11:14:29 +02:00

chore: first scratch at creating something

This commit is contained in:
Thomas Heartman 2024-01-04 14:50:55 +05:30
parent efa2117ded
commit eb03462599
No known key found for this signature in database
GPG Key ID: BD1F880DAED1EE78

View File

@ -0,0 +1,36 @@
import { FC } from 'react';
import { useLocationSettings } from 'hooks/useLocationSettings';
import {
formatDateHM,
formatDateYMD,
formatDateYMDHM,
formatDateYMDHMS,
} from './formatDate';
type DateDisplayProps = {
displayFormat: 'YMD' | 'HM' | 'YMDHMS' | 'YMDHM';
date: Date | string;
};
// You are responsible for ensuring that the string / number you pass in is valid.
export const DisplayDate: FC<DateDisplayProps> = ({ displayFormat, date }) => {
const { locationSettings } = useLocationSettings();
const locale = locationSettings?.locale;
const format = (() => {
switch (displayFormat) {
case 'HM':
return formatDateHM;
case 'YMD':
return formatDateYMD;
case 'YMDHM':
return formatDateYMDHM;
case 'YMDHMS':
return formatDateYMDHMS;
}
})();
const formattedDate = format(date, locale);
return <time>{formattedDate}</time>;
};