mirror of
https://github.com/luxfi/explore.git
synced 2026-09-24 00:28:18 +00:00
25 lines
741 B
TypeScript
25 lines
741 B
TypeScript
import React from 'react';
|
|
|
|
import { useSettingsContext } from 'lib/contexts/settings';
|
|
import dayjs, { FORMATS } from 'lib/date/dayjs';
|
|
|
|
interface Props extends React.HTMLAttributes<HTMLSpanElement> {
|
|
timestamp: string | number;
|
|
format?: string;
|
|
color?: string;
|
|
fontWeight?: string;
|
|
display?: string;
|
|
mt?: string;
|
|
textAlign?: string;
|
|
flexShrink?: number;
|
|
ml?: string;
|
|
}
|
|
|
|
const Time = ({ timestamp, format = 'lll', className, ...rest }: Props) => {
|
|
const settings = useSettingsContext();
|
|
const formatStr = FORMATS[format as keyof typeof FORMATS] || format;
|
|
return <span className={ className } { ...rest }>{ dayjs(timestamp).utc(settings?.isLocalTime).format(formatStr) }</span>;
|
|
};
|
|
|
|
export default React.memo(Time);
|