Injection token that provides NamedFormat to RawFormat conversion used throughout the module
Format for pipes
Named format for pipes
Raw format for pipes - a string of moment.js tokens
Default formats used by this module. You can re-use and extend it when creating a custom formats object.
Helper that checks whether a string is one of known NamedFormat values
Generated using TypeDoc
@ization/moment
Install
Install ization Core, this plugin, and other required packages:
Configure
Configure
@ization/corefirst. Then, import the main module of this plugin into your app module usingIzMomentModulestatic method and define configuration of this plugin:Optionally, you can provide your own formats for each pipe. To do that, import this plugin using
IzMomentModule.withCustomFormatsstatic method instead:You can override locale code used by this plugin in
IzCoreModule.withLocalesobject viamomentLocaleCodeproperty.Use
izMDatePipeinput- Date ISO string, date-time ISO string, ormomentinstance to localize.format- Format to use. Can be either one of strings'short' | 'medium' | 'long'or an arbitrary string withmoment#formattokens.Returns string that represents the input localized as a date. Until
@ization/coreis initialized, returns empty string. When invalid input is provided, returns'Invalid date'string.izMTimePipeinput- Time ISO string, date-time ISO string, ormomentinstance to localize.format- Format to use. Can be either one of strings'short' | 'medium' | 'long'or an arbitrary string withmoment#formattokens.Returns string that represents the input localized as a time. Until
@ization/coreis initialized, returns empty string. When invalid input is provided, returns'Invalid date'string.izMDateTimePipeinput- Date-time ISO string ormomentinstance to localize.format- Format to use. Can be either one of strings'short' | 'medium' | 'long'or an arbitrary string withmoment#formattokens.Returns string that represents the input localized as a date & time. Until
@ization/coreis initialized, returns empty string. When invalid input is provided, returns'Invalid date'string.izMYearMonthPipeinput- Year-month ISO string, date ISO string, date-time ISO string, ormomentinstance to localize.format- Format to use. Can be either one of strings'short' | 'medium' | 'long'or an arbitrary string withmoment#formattokens.Returns string that represents the input localized as a year & month. Until
@ization/coreis initialized, returns empty string. When invalid input is provided, returns'Invalid date'string.izMWeekdayPipeinput- Date ISO string, date-time ISO string, ormomentinstance to localize.format- Format to use. Can be either one of strings'short' | 'medium' | 'long'or an arbitrary string withmoment#formattokens.Returns string that represents the input localized as a weekday. Until
@ization/coreis initialized, returns empty string. When invalid input is provided, returns'Invalid date'string.Develop
Build
Run
npm run build:momentto build the package into thedist/moment/directory.Unit tests
Run
npm run test:momentto execute the unit tests.Linter
Run
npm run lint:momentto run linter on all code, including spec files.