diff --git a/services/web/frontend/js/features/history/components/change-list/label-list-item.tsx b/services/web/frontend/js/features/history/components/change-list/label-list-item.tsx
index c1223d7ec7..fbf291113c 100644
--- a/services/web/frontend/js/features/history/components/change-list/label-list-item.tsx
+++ b/services/web/frontend/js/features/history/components/change-list/label-list-item.tsx
@@ -1,7 +1,7 @@
import { memo, useCallback } from 'react'
import { UpdateRange, Version } from '../../services/types/update'
import TagTooltip from './tag-tooltip'
-import { formatTimeBasedOnYear } from '../../../utils/format-date'
+import { FormatTimeBasedOnYear } from '@/shared/components/format-time-based-on-year'
import HistoryDropdown from './dropdown/history-dropdown'
import HistoryVersionDetails from './history-version-details'
import { LoadedLabel } from '../../services/types/label'
@@ -145,7 +145,7 @@ function LabelListItem({
data-testid="history-version-metadata-time"
>
{t('last_edit')}{' '}
- {formatTimeBasedOnYear(label.lastUpdatedTimestamp)}
+
)}
diff --git a/services/web/frontend/js/features/history/components/change-list/tag-tooltip.tsx b/services/web/frontend/js/features/history/components/change-list/tag-tooltip.tsx
index 19b9c547ce..ffc6ae208a 100644
--- a/services/web/frontend/js/features/history/components/change-list/tag-tooltip.tsx
+++ b/services/web/frontend/js/features/history/components/change-list/tag-tooltip.tsx
@@ -16,7 +16,7 @@ import { deleteLabel } from '../../services/api'
import { isPseudoLabel } from '../../utils/label'
import { LoadedLabel } from '../../services/types/label'
import { debugConsole } from '@/utils/debugging'
-import { formatTimeBasedOnYear } from '@/features/utils/format-date'
+import { FormatTimeBasedOnYear } from '@/shared/components/format-time-based-on-year'
import { useEditorContext } from '@/shared/context/editor-context'
import OLTag from '@/features/ui/components/ol/ol-tag'
import OLButton from '@/features/ui/components/ol/ol-button'
@@ -172,7 +172,9 @@ function TagTooltip({ label, currentUserId, showTooltip }: LabelBadgesProps) {
{t('history_label_created_by')} {labelOwnerName}
-
- {formatTimeBasedOnYear(change.metadata?.ts)}
-
+ {change.metadata?.ts && (
+
+
+
+ )}
{editable && (
diff --git a/services/web/frontend/js/features/review-panel-new/components/review-panel-message.tsx b/services/web/frontend/js/features/review-panel-new/components/review-panel-message.tsx
index 34cb336be9..028b2afd38 100644
--- a/services/web/frontend/js/features/review-panel-new/components/review-panel-message.tsx
+++ b/services/web/frontend/js/features/review-panel-new/components/review-panel-message.tsx
@@ -4,7 +4,7 @@ import {
ReviewPanelCommentThreadMessage,
} from '../../../../../types/review-panel/review-panel'
import { useTranslation } from 'react-i18next'
-import { formatTimeBasedOnYear } from '@/features/utils/format-date'
+import { FormatTimeBasedOnYear } from '@/shared/components/format-time-based-on-year'
import OLTooltip from '@/features/ui/components/ol/ol-tooltip'
import MaterialIcon from '@/shared/components/material-icon'
import AutoExpandingTextArea from '@/shared/components/auto-expanding-text-area'
@@ -64,7 +64,7 @@ export const ReviewPanelMessage: FC<{
- {formatTimeBasedOnYear(message.timestamp)}
+
diff --git a/services/web/frontend/js/features/review-panel-new/components/review-panel-resolved-message.tsx b/services/web/frontend/js/features/review-panel-new/components/review-panel-resolved-message.tsx
index 6c207f71bc..c7f0d96167 100644
--- a/services/web/frontend/js/features/review-panel-new/components/review-panel-resolved-message.tsx
+++ b/services/web/frontend/js/features/review-panel-new/components/review-panel-resolved-message.tsx
@@ -1,5 +1,5 @@
import { FC } from 'react'
-import { formatTimeBasedOnYear } from '@/features/utils/format-date'
+import { FormatTimeBasedOnYear } from '@/shared/components/format-time-based-on-year'
import { ReviewPanelResolvedCommentThread } from '../../../../../types/review-panel/comment-thread'
import { useTranslation } from 'react-i18next'
import ReviewPanelEntryUser from './review-panel-entry-user'
@@ -15,7 +15,7 @@ const ReviewPanelResolvedMessage: FC<{
- {formatTimeBasedOnYear(thread.resolved_at)}
+
diff --git a/services/web/frontend/js/features/utils/format-date.js b/services/web/frontend/js/features/utils/format-date.ts
similarity index 71%
rename from services/web/frontend/js/features/utils/format-date.js
rename to services/web/frontend/js/features/utils/format-date.ts
index 8d748ae291..5210bf6962 100644
--- a/services/web/frontend/js/features/utils/format-date.js
+++ b/services/web/frontend/js/features/utils/format-date.ts
@@ -11,15 +11,15 @@ moment.updateLocale('en', {
},
})
-export function formatTime(date, format = 'h:mm a') {
+export function formatTime(date: moment.MomentInput, format = 'h:mm a') {
return moment(date).format(format)
}
-export function relativeDate(date) {
+export function relativeDate(date: moment.MomentInput) {
return moment(date).calendar()
}
-export function formatTimeBasedOnYear(date) {
+export function formatTimeBasedOnYear(date: moment.MomentInput) {
const currentDate = moment()
return currentDate.diff(date, 'years') > 0
diff --git a/services/web/frontend/js/shared/components/format-time-based-on-year.tsx b/services/web/frontend/js/shared/components/format-time-based-on-year.tsx
new file mode 100644
index 0000000000..86a105a6d0
--- /dev/null
+++ b/services/web/frontend/js/shared/components/format-time-based-on-year.tsx
@@ -0,0 +1,8 @@
+import { memo } from 'react'
+import { formatTimeBasedOnYear } from '@/features/utils/format-date'
+
+export const FormatTimeBasedOnYear = memo<{ date: string | number | Date }>(
+ function FormatTimeBasedOnYear({ date }) {
+ return <>{formatTimeBasedOnYear(date)}>
+ }
+)
diff --git a/services/web/test/frontend/features/history/components/change-list-bs5.spec.tsx b/services/web/test/frontend/features/history/components/change-list-bs5.spec.tsx
index c950bb41ad..391ca667d4 100644
--- a/services/web/test/frontend/features/history/components/change-list-bs5.spec.tsx
+++ b/services/web/test/frontend/features/history/components/change-list-bs5.spec.tsx
@@ -10,10 +10,7 @@ import {
import { HistoryProvider } from '../../../../../frontend/js/features/history/context/history-context'
import { updates } from '../fixtures/updates'
import { labels } from '../fixtures/labels'
-import {
- formatTime,
- relativeDate,
-} from '../../../../../frontend/js/features/utils/format-date'
+import { formatTime, relativeDate } from '@/features/utils/format-date'
const mountWithEditorProviders = (
component: React.ReactNode,
diff --git a/services/web/test/frontend/features/history/components/change-list.spec.tsx b/services/web/test/frontend/features/history/components/change-list.spec.tsx
index 051a5b63bf..56f598ef8b 100644
--- a/services/web/test/frontend/features/history/components/change-list.spec.tsx
+++ b/services/web/test/frontend/features/history/components/change-list.spec.tsx
@@ -10,10 +10,7 @@ import {
import { HistoryProvider } from '../../../../../frontend/js/features/history/context/history-context'
import { updates } from '../fixtures/updates'
import { labels } from '../fixtures/labels'
-import {
- formatTime,
- relativeDate,
-} from '../../../../../frontend/js/features/utils/format-date'
+import { formatTime, relativeDate } from '@/features/utils/format-date'
const mountWithEditorProviders = (
component: React.ReactNode,