mirror of
https://github.com/luxfi/explore.git
synced 2026-09-24 00:28:18 +00:00
* add global setting to change between local and utc time * add control to change time format on detailed views * tweaks * adapt uptime graphs to work with utc time from settings * fix tests * add maxDiffPixels for SearchResults test * fix test
20 lines
648 B
TypeScript
20 lines
648 B
TypeScript
import type { BoxProps } from '@chakra-ui/react';
|
|
import { chakra } from '@chakra-ui/react';
|
|
import React from 'react';
|
|
|
|
import { useSettingsContext } from 'lib/contexts/settings';
|
|
import dayjs, { FORMATS } from 'lib/date/dayjs';
|
|
|
|
interface Props extends BoxProps {
|
|
timestamp: string | number;
|
|
format?: string;
|
|
}
|
|
|
|
const Time = ({ timestamp, format = 'lll', ...rest }: Props) => {
|
|
const settings = useSettingsContext();
|
|
const formatStr = FORMATS[format as keyof typeof FORMATS] || format;
|
|
return <chakra.span { ...rest }>{ dayjs(timestamp).utc(settings?.isLocalTime).format(formatStr) }</chakra.span>;
|
|
};
|
|
|
|
export default React.memo(Time);
|