2022-08-13 00:48:41 +00:00
|
|
|
import dayjs, { Dayjs } from 'dayjs'
|
2022-01-16 09:16:15 +00:00
|
|
|
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: {
|
2022-08-13 00:48:41 +00:00
|
|
|
time: Dayjs
|
2022-01-19 22:01:54 +00:00
|
|
|
text?: string
|
2022-08-13 00:48:41 +00:00
|
|
|
className?: 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-13 00:48:41 +00:00
|
|
|
const { className, time, text, noTap } = props
|
2022-01-19 22:01:54 +00:00
|
|
|
|
2022-08-13 00:48:41 +00:00
|
|
|
const formattedTime = 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-13 00:48:41 +00:00
|
|
|
<Tooltip className={className} text={toolTip} noTap={noTap}>
|
2022-08-12 19:04:23 +00:00
|
|
|
{props.children}
|
|
|
|
</Tooltip>
|
2022-01-16 09:16:15 +00:00
|
|
|
)
|
|
|
|
}
|