@ization/moment v1.0.1
@ization/moment
ization plugin for date/time formatting of ISO strings or
momentinstances
Install
Install ization Core, this plugin, and other required packages:
npm install @ization/core @ization/moment momentConfigure
Configure @ization/core first. Then, import the main module of this plugin into your app module using IzMomentModule static method and define configuration of this plugin:
@NgModule({
imports: [
...
IzMomentModule,
...
],
...
})
export class AppModule {}Optionally, you can provide your own formats for each pipe. To do that, import this plugin using IzMomentModule.withCustomFormats static method instead:
@NgModule({
imports: [
...
IzMomentModule.withCustomFormats(myFormats),
...
],
...
})
export class AppModule {}You can override locale code used by this plugin in IzCoreModule.withLocales object via momentLocaleCode property.
Use
izMDate Pipe
input | izMDate: format
input- 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/core is initialized, returns empty string. When invalid input is provided, returns 'Invalid date' string.
izMTime Pipe
input | izMTime: format
input- 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/core is initialized, returns empty string. When invalid input is provided, returns 'Invalid date' string.
izMDateTime Pipe
input | izMDateTime: format
input- 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/core is initialized, returns empty string. When invalid input is provided, returns 'Invalid date' string.
izMYearMonth Pipe
input | izMYearMonth: format
input- 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/core is initialized, returns empty string. When invalid input is provided, returns 'Invalid date' string.
izMWeekday Pipe
input | izMWeekday: format
input- 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/core is initialized, returns empty string. When invalid input is provided, returns 'Invalid date' string.
Develop
Build
Run npm run build:moment to build the package into the dist/moment/ directory.
Unit tests
Run npm run test:moment to execute the unit tests.
Linter
Run npm run lint:moment to run linter on all code, including spec files.
License
This library is licensed under Parity 7.0.0 license. If you want to use this library in open source projects, go ahead, it's completely free! If you'd rather keep your code closed, you have 30 days to try the library in your project, then you need to buy a private license. Have a look at GitHub Sponsors or contact me directly at get@ization.dev to negotiate a deal.