CngxTime
projects/common/display/time/time.component.ts
Import#
import { CngxTime } from '@cngx/common/display'
Description#
Locale-aware <time> display atom. Renders a machine-readable
datetime attribute (ISO 8601) plus a human string in one of two modes:
absolute (via Intl.DateTimeFormat) or relative (via
Intl.RelativeTimeFormat, e.g. "3 days ago"). Formatting resolves against
the injected LOCALE_ID - English out of the box, locale-driven when the app
provides one; no hardcoded strings.
Relative mode is render-time, not live-ticking: it recomputes when [date]
changes, not on a timer, so "2 minutes ago" does not self-update. A consumer
that needs a live clock re-binds [date]; a timer-driven variant is an
explicit non-goal for the atom.
<cngx-time [date]="publishedAt()" mode="relative" />
<cngx-time [date]="invoice.due" [format]="{ dateStyle: 'long' }" />Metadata#
Index#
Inputs#
Date | string | numberInstant to render. Accepts a Date, an ISO string, or an epoch-ms number.
Intl.DateTimeFormatOptions | undefinedIntl.DateTimeFormatOptions for absolute mode; ignored in relative mode.
"absolute" | "relative"absolute formats a calendar date/time; relative formats the distance
from now (past or future) with Intl.RelativeTimeFormat.
'absolute'