mirror of
https://github.com/BerriAI/litellm.git
synced 2026-09-23 00:41:40 +00:00
feat(ui/agents): add _dayjs helper with relativeTime plugin
Centralizes dayjs.extend(relativeTime) so fromNow() is typed and loaded across the agents components. relativeOrAbsolute() falls back to '—' for null/invalid timestamps so callers don't have to re-implement the guard.
This commit is contained in:
parent
be5ac1885a
commit
d75651912e
1 changed files with 20 additions and 0 deletions
|
|
@ -0,0 +1,20 @@
|
|||
/**
|
||||
* Shared dayjs helper for the cloud-agents dashboard.
|
||||
*
|
||||
* Loads the `relativeTime` plugin once so `dayjs(...).fromNow()` is
|
||||
* typed and works across all the agents components. Without this, the
|
||||
* plugin call is untyped and TS rejects it.
|
||||
*/
|
||||
import dayjs from "dayjs";
|
||||
import relativeTime from "dayjs/plugin/relativeTime";
|
||||
|
||||
dayjs.extend(relativeTime);
|
||||
|
||||
export function relativeOrAbsolute(value: string | null | undefined): string {
|
||||
if (!value) return "—";
|
||||
const d = dayjs(value);
|
||||
if (!d.isValid()) return "—";
|
||||
return d.fromNow();
|
||||
}
|
||||
|
||||
export { dayjs };
|
||||
Loading…
Add table
Reference in a new issue