feat: 智能体与技能列表显示创建时间字段
- 新增共享 formatDateTime 工具(YYYY-MM-DD HH:mm) - agent-card 卡片/列表视图在发布者下方显示创建时间 - skill 设置页 metaNodes 显示创建时间 Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
1 parent
595da9f339
commit
74113b3e6e
3 files changed
+39
No files matched your search
@@ -25,3 +25,18 @@ export function formatTimeAgo(date: Date | string | number, locale?: Locale) {
|
||||
locale: getDateFnsLocale(effectiveLocale),
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Format a created/updated timestamp as `YYYY-MM-DD HH:mm`.
|
||||
* Returns an empty string for missing or unparseable values.
|
||||
*/
|
||||
export function formatDateTime(value?: Date | string | number | null): string {
|
||||
if (value === null || value === undefined || value === "") return "";
|
||||
const date = value instanceof Date ? value : new Date(value);
|
||||
if (Number.isNaN(date.getTime())) return "";
|
||||
const pad = (n: number) => String(n).padStart(2, "0");
|
||||
return (
|
||||
`${date.getFullYear()}-${pad(date.getMonth() + 1)}-${pad(date.getDate())} ` +
|
||||
`${pad(date.getHours())}:${pad(date.getMinutes())}`
|
||||
);
|
||||
}
|
||||
Reference in new issue
Block a user