diff --git a/frontend/src/components/TagDetailSidebar.tsx b/frontend/src/components/TagDetailSidebar.tsx
index 64dbfe3..b4be734 100644
--- a/frontend/src/components/TagDetailSidebar.tsx
+++ b/frontend/src/components/TagDetailSidebar.tsx
@@ -19,6 +19,7 @@ import SidebarComponent from '@/components/layout/SidebarComponent'
import { toast } from '@/components/ui/use-toast'
import { CATEGORIES } from '@/consts'
import { apiDelete, apiGet, apiPatch, apiPost } from '@/lib/api'
+import { dateString, originalCreatedAtString } from '@/lib/utils'
import type { DragEndEvent } from '@dnd-kit/core'
import type { FC, MutableRefObject, ReactNode } from 'react'
@@ -343,7 +344,7 @@ export default (({ post }: Props) => {
: 'bot操作'}
*/}
-
耕作日時: {(new Date (post.createdAt)).toLocaleString ()}
+ 耕作日時: {dateString (post.createdAt)}
<>リンク: >
{
- {/* TODO: 表示形式きしょすぎるので何とかする */}
<>オリジナルの投稿日時: >
- {!(post.originalCreatedFrom) && !(post.originalCreatedBefore)
- ? '不明'
- : (
- <>
- {post.originalCreatedFrom
- && `${ (new Date (post.originalCreatedFrom)).toLocaleString () } 以降 `}
- {post.originalCreatedBefore
- && `${ (new Date (post.originalCreatedBefore)).toLocaleString () } より前`}
- >)}
+ {originalCreatedAtString (post.originalCreatedFrom,
+ post.originalCreatedBefore)}
- 履歴
+
+ 履歴
+
)}
diff --git a/frontend/src/lib/utils.ts b/frontend/src/lib/utils.ts
index 871bdd6..95caded 100644
--- a/frontend/src/lib/utils.ts
+++ b/frontend/src/lib/utils.ts
@@ -4,4 +4,23 @@ import { twMerge } from 'tailwind-merge'
import type { ClassValue } from 'clsx'
+export const toDate = (d: string | Date): Date => typeof d === 'string' ? new Date (d) : d
+
+
export const cn = (...inputs: ClassValue[]) => twMerge (clsx (...inputs))
+
+
+export const dateString = (d: string | Date): string =>
+ toDate (d).toLocaleString ('ja-JP-u-ca-japanese')
+
+
+// TODO: 表示形式きしょすぎるので何とかする
+export const originalCreatedAtString = (
+ f: string | Date | null,
+ b: string | Date | null,
+): string =>
+ ([f ? `${ dateString (f) } 以降` : '',
+ b ? `${ dateString (b) } より前` : '']
+ .filter (Boolean)
+ .join (' '))
+ || '不明'
diff --git a/frontend/src/pages/posts/PostHistoryPage.tsx b/frontend/src/pages/posts/PostHistoryPage.tsx
index dbf65dc..7fe2202 100644
--- a/frontend/src/pages/posts/PostHistoryPage.tsx
+++ b/frontend/src/pages/posts/PostHistoryPage.tsx
@@ -1,4 +1,5 @@
import { useQuery } from '@tanstack/react-query'
+import { motion } from 'framer-motion'
import { useEffect } from 'react'
import { Helmet } from 'react-helmet-async'
import { useLocation } from 'react-router-dom'
@@ -11,7 +12,7 @@ import MainArea from '@/components/layout/MainArea'
import { SITE_TITLE } from '@/config'
import { fetchPostChanges } from '@/lib/posts'
import { postsKeys } from '@/lib/queryKeys'
-import { cn } from '@/lib/utils'
+import { cn, dateString } from '@/lib/utils'
import type { FC } from 'react'
@@ -77,10 +78,17 @@ export default (() => {
-
+
+
+
| )}
@@ -88,12 +96,14 @@ export default (() => {
{`を${ change.changeType === 'add' ? '記載' : '消除' }`}
|
- {change.user ? (
+ {change.user
+ ? (
{change.user.name}
- ) : 'bot 操作'}
+ )
+ : 'bot 操作'}
- {change.timestamp}
+ {dateString (change.timestamp)}
|
)
})}
diff --git a/frontend/src/pages/posts/PostSearchPage.tsx b/frontend/src/pages/posts/PostSearchPage.tsx
index 58bf877..e100d5b 100644
--- a/frontend/src/pages/posts/PostSearchPage.tsx
+++ b/frontend/src/pages/posts/PostSearchPage.tsx
@@ -1,4 +1,5 @@
import { useQuery } from '@tanstack/react-query'
+import { motion } from 'framer-motion'
import { useEffect, useMemo, useState } from 'react'
import { Helmet } from 'react-helmet-async'
import { useLocation, useNavigate } from 'react-router-dom'
@@ -15,6 +16,7 @@ import { SITE_TITLE } from '@/config'
import { apiGet } from '@/lib/api'
import { fetchPosts } from '@/lib/posts'
import { postsKeys } from '@/lib/queryKeys'
+import { dateString, originalCreatedAtString } from '@/lib/utils'
import type { FC, ChangeEvent, FormEvent, KeyboardEvent } from 'react'
@@ -359,10 +361,17 @@ export default (() => {
-
+
+
+
|
@@ -385,10 +394,11 @@ export default (() => {
))}
|
- {row.originalCreatedFrom} 〜 {row.originalCreatedBefore}
+ {originalCreatedAtString (row.originalCreatedFrom,
+ row.originalCreatedBefore)}
|
- {row.createdAt} |
- {row.updatedAt} |
+ {dateString (row.createdAt)} |
+ {dateString (row.updatedAt)} |
))}
diff --git a/frontend/src/pages/wiki/WikiHistoryPage.tsx b/frontend/src/pages/wiki/WikiHistoryPage.tsx
index 1ed278a..056e937 100644
--- a/frontend/src/pages/wiki/WikiHistoryPage.tsx
+++ b/frontend/src/pages/wiki/WikiHistoryPage.tsx
@@ -7,6 +7,7 @@ import PageTitle from '@/components/common/PageTitle'
import MainArea from '@/components/layout/MainArea'
import { SITE_TITLE } from '@/config'
import { apiGet } from '@/lib/api'
+import { dateString } from '@/lib/utils'
import type { WikiPageChange } from '@/types'
@@ -65,7 +66,7 @@ export default () => {
{change.user.name}
- {change.timestamp}
+ {dateString (change.timestamp)}
))}
diff --git a/frontend/src/pages/wiki/WikiSearchPage.tsx b/frontend/src/pages/wiki/WikiSearchPage.tsx
index bc3e3e7..73f23a8 100644
--- a/frontend/src/pages/wiki/WikiSearchPage.tsx
+++ b/frontend/src/pages/wiki/WikiSearchPage.tsx
@@ -6,6 +6,7 @@ import PageTitle from '@/components/common/PageTitle'
import MainArea from '@/components/layout/MainArea'
import { SITE_TITLE } from '@/config'
import { apiGet } from '@/lib/api'
+import { dateString } from '@/lib/utils'
import type { FormEvent } from 'react'
@@ -84,7 +85,7 @@ export default () => {
- {page.updatedAt}
+ {dateString (page.updatedAt)}
|
))}