API Reference / @dasch-ng/utils / intl/src / IntlRelativeTimePipe
Class: IntlRelativeTimePipe
Defined in: libs/ng/utils/intl/src/lib/intl-relative-time.pipe.ts:35
Formats the distance from now to a date with Intl.RelativeTimeFormat, choosing the unit automatically: 3 minutes ago, in 2 days, yesterday (numeric: 'auto' is the default).
The pipe is pure, so the text only changes when the input changes. To keep it current, pass a ticking now, e.g. from a signal updated every minute.
Example
{{ comment.createdAt | intlRelativeTime }} <!-- 5 minutes ago -->
{{ comment.createdAt | intlRelativeTime: { now: now() } }}
{{ deadline | intlRelativeTime: { style: 'short' } : 'de-DE' }} <!-- in 3 Tagen -->Extends
IntlPipeBase
Implements
PipeTransform
Constructors
Constructor
new IntlRelativeTimePipe():
IntlRelativeTimePipe
Returns
IntlRelativeTimePipe
Inherited from
IntlPipeBase.constructor
Methods
locale()
protectedlocale(locale?):string
Defined in: libs/ng/utils/intl/src/lib/formatter-cache.ts:29
Parameters
locale?
string
Returns
string
Inherited from
IntlPipeBase.locale
transform()
transform(
value,options?,locale?):string|null
Defined in: libs/ng/utils/intl/src/lib/intl-relative-time.pipe.ts:36
Parameters
value
string | number | Date | null | undefined
options?
locale?
string
Returns
string | null
Implementation of
PipeTransform.transform