diff --git a/web/components/contract/contract-details.tsx b/web/components/contract/contract-details.tsx
index 081b035d..4a9d40af 100644
--- a/web/components/contract/contract-details.tsx
+++ b/web/components/contract/contract-details.tsx
@@ -83,12 +83,10 @@ export function MiscDetails(props: {
{!hideGroupLink && groupLinks && groupLinks.length > 0 && (
-
-
- {groupLinks[0].name}
-
+
+ {groupLinks[0].name}
)}
@@ -211,7 +209,7 @@ export function ContractDetails(props: {
<>
{resolvedDate}
@@ -267,13 +265,16 @@ function EditableCloseDate(props: {
}) {
const { closeTime, contract, isCreator } = props
+ const dayJsCloseTime = dayjs(closeTime)
+ const dayJsNow = dayjs()
+
const [isEditingCloseTime, setIsEditingCloseTime] = useState(false)
const [closeDate, setCloseDate] = useState(
- closeTime && dayjs(closeTime).format('YYYY-MM-DDTHH:mm')
+ closeTime && dayJsCloseTime.format('YYYY-MM-DDTHH:mm')
)
- const isSameYear = dayjs(closeTime).isSame(dayjs(), 'year')
- const isSameDay = dayjs(closeTime).isSame(dayjs(), 'day')
+ const isSameYear = dayJsCloseTime.isSame(dayJsNow, 'year')
+ const isSameDay = dayJsCloseTime.isSame(dayJsNow, 'day')
const onSave = () => {
const newCloseTime = dayjs(closeDate).valueOf()
@@ -314,11 +315,11 @@ function EditableCloseDate(props: {
) : (
Date.now() ? 'Trading ends:' : 'Trading ended:'}
- time={closeTime}
+ time={dayJsCloseTime}
>
{isSameYear
- ? dayjs(closeTime).format('MMM D')
- : dayjs(closeTime).format('MMM D, YYYY')}
+ ? dayJsCloseTime.format('MMM D')
+ : dayJsCloseTime.format('MMM D, YYYY')}
{isSameDay && <> ({fromNow(closeTime)})>}
)}
diff --git a/web/components/datetime-tooltip.tsx b/web/components/datetime-tooltip.tsx
index 7aaf61aa..d820e728 100644
--- a/web/components/datetime-tooltip.tsx
+++ b/web/components/datetime-tooltip.tsx
@@ -1,4 +1,4 @@
-import dayjs from 'dayjs'
+import dayjs, { Dayjs } from 'dayjs'
import utc from 'dayjs/plugin/utc'
import timezone from 'dayjs/plugin/timezone'
import advanced from 'dayjs/plugin/advancedFormat'
@@ -9,18 +9,19 @@ dayjs.extend(timezone)
dayjs.extend(advanced)
export function DateTimeTooltip(props: {
- time: number
+ time: Dayjs
text?: string
+ className?: string
children?: React.ReactNode
noTap?: boolean
}) {
- const { time, text, noTap } = props
+ const { className, time, text, noTap } = props
- const formattedTime = dayjs(time).format('MMM DD, YYYY hh:mm a z')
+ const formattedTime = time.format('MMM DD, YYYY hh:mm a z')
const toolTip = text ? `${text} ${formattedTime}` : formattedTime
return (
-
+
{props.children}
)
diff --git a/web/components/feed/copy-link-date-time.tsx b/web/components/feed/copy-link-date-time.tsx
index cea8300a..8238d3e3 100644
--- a/web/components/feed/copy-link-date-time.tsx
+++ b/web/components/feed/copy-link-date-time.tsx
@@ -7,6 +7,7 @@ import { fromNow } from 'web/lib/util/time'
import { ToastClipboard } from 'web/components/toast-clipboard'
import { LinkIcon } from '@heroicons/react/outline'
import clsx from 'clsx'
+import dayjs from 'dayjs'
export function CopyLinkDateTimeComponent(props: {
prefix: string
@@ -17,6 +18,7 @@ export function CopyLinkDateTimeComponent(props: {
}) {
const { prefix, slug, elementId, createdTime, className } = props
const [showToast, setShowToast] = useState(false)
+ const time = dayjs(createdTime)
function copyLinkToComment(
event: React.MouseEvent
@@ -30,7 +32,7 @@ export function CopyLinkDateTimeComponent(props: {
}
return (