Enhance frontend documentation and UI components; update frontend-shadcn.mdc to include UI patterns reference; improve navigation structure in AppSidebar by categorizing items; refactor DataTableCard to support empty states with EmptyState component; implement ConfirmDialog for delete actions in DnsRecordsTable and GroupsPage; add search functionality in CertificatesPage and GroupsPage for better user experience; update ServiceEditSheet to utilize tabs for organization.
Build, Test, and Push CFDM Docker Image / test (push) Has been cancelled
Build, Test, and Push CFDM Docker Image / build-and-push (push) Has been cancelled
Build, Test, and Push CFDM Docker Image / create-release (push) Has been cancelled
Build, Test, and Push CFDM Docker Image / update-wiki (push) Has been cancelled
Build, Test, and Push CFDM Docker Image / test (push) Has been cancelled
Build, Test, and Push CFDM Docker Image / build-and-push (push) Has been cancelled
Build, Test, and Push CFDM Docker Image / create-release (push) Has been cancelled
Build, Test, and Push CFDM Docker Image / update-wiki (push) Has been cancelled
This commit is contained in:
@@ -0,0 +1,31 @@
|
||||
const dateFormatter = new Intl.DateTimeFormat('ru-RU', {
|
||||
dateStyle: 'medium',
|
||||
timeStyle: 'short',
|
||||
})
|
||||
|
||||
const relativeFormatter = new Intl.RelativeTimeFormat('ru', { numeric: 'auto' })
|
||||
|
||||
export function formatDate(iso: string | null | undefined): string {
|
||||
if (!iso) return '—'
|
||||
const date = new Date(iso)
|
||||
if (Number.isNaN(date.getTime())) return iso
|
||||
return dateFormatter.format(date)
|
||||
}
|
||||
|
||||
export function formatRelative(iso: string | null | undefined): string {
|
||||
if (!iso) return '—'
|
||||
const date = new Date(iso)
|
||||
if (Number.isNaN(date.getTime())) return iso
|
||||
const diffMs = date.getTime() - Date.now()
|
||||
const diffSec = Math.round(diffMs / 1000)
|
||||
const absSec = Math.abs(diffSec)
|
||||
|
||||
if (absSec < 60) return relativeFormatter.format(diffSec, 'second')
|
||||
const diffMin = Math.round(diffSec / 60)
|
||||
if (Math.abs(diffMin) < 60) return relativeFormatter.format(diffMin, 'minute')
|
||||
const diffHour = Math.round(diffMin / 60)
|
||||
if (Math.abs(diffHour) < 24) return relativeFormatter.format(diffHour, 'hour')
|
||||
const diffDay = Math.round(diffHour / 24)
|
||||
if (Math.abs(diffDay) < 30) return relativeFormatter.format(diffDay, 'day')
|
||||
return formatDate(iso)
|
||||
}
|
||||
Reference in New Issue
Block a user