【再掲】タグの局所記載 (#351) (#380)

#353 を再開できなかったので.

Reviewed-on: #380
Co-authored-by: miteruzo <miteruzo@naver.com>
Co-committed-by: miteruzo <miteruzo@naver.com>
このコミットはPull リクエスト #380 でマージされました.
このコミットが含まれているのは:
2026-07-03 03:23:36 +09:00
committed by みてるぞ
コミット fdf652951a
32個のファイルの変更920行の追加63行の削除
+2
ファイルの表示
@@ -70,6 +70,7 @@ describe ('posts API functions', () => {
id: 5,
title: 'new title',
tags: 'tag',
duration: null,
parentPostIds: '1 2',
originalCreatedFrom: null,
originalCreatedBefore: '2026-01-02T00:00:00Z',
@@ -82,6 +83,7 @@ describe ('posts API functions', () => {
{
title: 'new title',
tags: 'tag',
duration: null,
parent_post_ids: '1 2',
original_created_from: null,
original_created_before: '2026-01-02T00:00:00Z',
+2
ファイルの表示
@@ -44,6 +44,7 @@ export const updatePost = async (
post: { id: number
title: string | null
tags: string
duration: string | null
parentPostIds: string
originalCreatedFrom: string | null
originalCreatedBefore: string | null },
@@ -55,6 +56,7 @@ export const updatePost = async (
`/posts/${ post.id }`,
{ title: post.title,
tags: post.tags,
duration: post.duration,
parent_post_ids: post.parentPostIds,
original_created_from: post.originalCreatedFrom,
original_created_before: post.originalCreatedBefore },
+12 -1
ファイルの表示
@@ -1,6 +1,6 @@
import { describe, expect, it } from 'vitest'
import { cn, originalCreatedAtString, toDate } from '@/lib/utils'
import { cn, msToTime, originalCreatedAtString, toDate } from '@/lib/utils'
describe ('utils', () => {
it ('converts strings to dates and leaves date instances intact', () => {
@@ -26,3 +26,14 @@ describe ('utils', () => {
).toContain ('時刻不詳')
})
})
describe ('msToTime', () => {
it ('keeps milliseconds when present', () => {
expect (msToTime (60_500)).toBe ('1:00.500')
expect (msToTime (60_001)).toBe ('1:00.001')
})
it ('omits milliseconds when they are zero', () => {
expect (msToTime (60_000)).toBe ('1:00')
})
})
+16
ファイルの表示
@@ -71,6 +71,22 @@ export const originalCreatedAtString = (
}
export const msToTime = (ms: number): string => {
const totalS = Math.trunc (ms / 1_000)
const s = String (totalS % 60)
const min = String (Math.trunc (totalS / 60) % 60)
const h = Math.trunc (totalS / 3_600)
const remainderMs = ms % 1_000
const base =
(h > 0
? `${ h }:${ min.padStart (2, '0') }:${ s.padStart (2, '0') }`
: `${ min }:${ s.padStart (2, '0') }`)
return remainderMs > 0 ? `${ base }.${ remainderMs.toString ().padStart (3, '0') }` : base
}
export const inputClass = (invalid?: boolean, className?: string): string =>
cn ('w-full rounded border p-2',
(invalid