2022-01-16 09:16:15 +00:00
|
|
|
import dayjs from 'dayjs'
|
|
|
|
import utc from 'dayjs/plugin/utc'
|
|
|
|
import timezone from 'dayjs/plugin/timezone'
|
|
|
|
import advanced from 'dayjs/plugin/advancedFormat'
|
2022-08-12 19:04:23 +00:00
|
|
|
import { Tooltip } from './tooltip'
|
2022-01-16 09:16:15 +00:00
|
|
|
|
|
|
|
dayjs.extend(utc)
|
|
|
|
dayjs.extend(timezone)
|
|
|
|
dayjs.extend(advanced)
|
|
|
|
|
|
|
|
export function DateTimeTooltip(props: {
|
|
|
|
time: number
|
2022-01-19 22:01:54 +00:00
|
|
|
text?: string
|
2022-01-16 09:16:15 +00:00
|
|
|
children?: React.ReactNode
|
2022-08-12 19:04:23 +00:00
|
|
|
noTap?: boolean
|
2022-01-16 09:16:15 +00:00
|
|
|
}) {
|
2022-08-12 19:04:23 +00:00
|
|
|
const { time, text, noTap } = props
|
2022-01-19 22:01:54 +00:00
|
|
|
|
2022-02-22 21:14:52 +00:00
|
|
|
const formattedTime = dayjs(time).format('MMM DD, YYYY hh:mm a z')
|
2022-01-19 22:01:54 +00:00
|
|
|
const toolTip = text ? `${text} ${formattedTime}` : formattedTime
|
|
|
|
|
2022-01-16 09:16:15 +00:00
|
|
|
return (
|
2022-08-12 19:04:23 +00:00
|
|
|
<Tooltip text={toolTip} noTap={noTap}>
|
|
|
|
{props.children}
|
|
|
|
</Tooltip>
|
2022-01-16 09:16:15 +00:00
|
|
|
)
|
|
|
|
}
|