@ization/temporal v1.0.1
@ization/temporal
ization plugin for date/time formatting of various
Temporalobjects
Install
Install ization Core, this plugin, and other required packages:
npm install @ization/core @ization/temporal @js-temporal/polyfillConfigure
Configure @ization/core first. Then, import the main module of this plugin into your app module using IzTemporalModule static method and define configuration of this plugin:
@NgModule({
imports: [
...
IzTemporalModule,
...
],
...
})
export class AppModule {}Optionally, you can provide your own formats for each pipe. To do that, import this plugin using IzTemporalModule.withCustomFormats static method instead:
@NgModule({
imports: [
...
IzTemporalModule.withCustomFormats(myFormats),
...
],
...
})
export class AppModule {}You can override locale code used by this plugin in IzCoreModule.withLocales object via temporalLocaleCode property.
Use
izDate Pipe
temporalObj | izDate: format
temporalObj-Temporal.PlainDateorTemporal.PlainDateTimeinstance to localize.format- Format to use. Can be either one of strings'short' | 'medium' | 'long'or an object conforming toDateFormatOptionsinterface.
Returns string that represents the input localized as a date. Until @ization/core is initialized, returns empty string.
izZonedDate Pipe
temporalObj | izZonedDate: format
temporalObj-Temporal.ZonedDateTimeinstance to localize.format- Format to use. Can be either one of strings'short' | 'medium' | 'long'or an object conforming toDateFormatOptionsinterface.
Returns string that represents the input localized as a date in provided time zone. Until @ization/core is initialized, returns empty string.
IzLocalDatePipe Pipe
temporalObj | IzLocalDatePipe: format
temporalObj-Temporal.ZonedDateTimeorTemporal.Instantinstance to localize.format- Format to use. Can be either one of strings'short' | 'medium' | 'long'or an object conforming toDateFormatOptionsinterface.
Returns string that represents the input localized as a date converted to local time zone. Until @ization/core is initialized, returns empty string.
izTime Pipe
temporalObj | izTime: format
temporalObj-Temporal.PlainTimeorTemporal.PlainDateTimeinstance to localize.format- Format to use. Can be either one of strings'short' | 'medium' | 'long'or an object conforming toTimeFormatOptionsinterface.
Returns string that represents the input localized as a time. Until @ization/core is initialized, returns empty string.
izZonedTime Pipe
temporalObj | izZonedTime: format
temporalObj-Temporal.ZonedDateTimeinstance to localize.format- Format to use. Can be either one of strings'short' | 'medium' | 'long' | 'zonedShort' | 'zonedMedium' | 'zonedLong'or an object conforming toZonedTimeFormatOptionsinterface.
Returns string that represents the input localized as a time in provided time zone. Until @ization/core is initialized, returns empty string.
IzLocalTimePipe Pipe
temporalObj | IzLocalTimePipe: format
temporalObj-Temporal.ZonedDateTimeorTemporal.Instantinstance to localize.format- Format to use. Can be either one of strings'short' | 'medium' | 'long' | 'zonedShort' | 'zonedMedium' | 'zonedLong'or an object conforming toZonedTimeFormatOptionsinterface.
Returns string that represents the input localized as a time converted to local time zone. Until @ization/core is initialized, returns empty string.
izDateTime Pipe
temporalObj | izDateTime: format
temporalObj-Temporal.PlainDateTimeinstance to localize.format- Format to use. Can be either one of strings'short' | 'medium' | 'long'or an object conforming toDateTimeFormatOptionsinterface.
Returns string that represents the input localized as a date & time. Until @ization/core is initialized, returns empty string.
izZonedDateTime Pipe
temporalObj | izZonedDateTime: format
temporalObj-Temporal.ZonedDateTimeinstance to localize.format- Format to use. Can be either one of strings'short' | 'medium' | 'long' | 'zonedShort' | 'zonedMedium' | 'zonedLong'or an object conforming toZonedDateTimeFormatOptionsinterface.
Returns string that represents the input localized as a date & time in provided time zone. Until @ization/core is initialized, returns empty string.
IzLocalDateTimePipe Pipe
temporalObj | IzLocalDateTimePipe: format
temporalObj-Temporal.ZonedDateTimeorTemporal.Instantinstance to localize.format- Format to use. Can be either one of strings'short' | 'medium' | 'long' | 'zonedShort' | 'zonedMedium' | 'zonedLong'or an object conforming toZonedDateTimeFormatOptionsinterface.
Returns string that represents the input localized as a date & time converted to local time zone. Until @ization/core is initialized, returns empty string.
izYearMonth Pipe
temporalObj | izYearMonth: format
temporalObj-Temporal.PlainDate,Temporal.PlainDateTime, orTemporal.PlainYearMonthinstance to localize.format- Format to use. Can be either one of strings'short' | 'medium' | 'long'or an object conforming toYearMonthFormatOptionsinterface.
Returns string that represents the input localized as a year & month. Until @ization/core is initialized, returns empty string.
izMonthDay Pipe
temporalObj | izMonthDay: format
temporalObj-Temporal.PlainDate,Temporal.PlainDateTime, orTemporal.PlainMonthDayinstance to localize.format- Format to use. Can be either one of strings'short' | 'medium' | 'long'or an object conforming toMonthDayFormatOptionsinterface.
Returns string that represents the input localized as a month & day. Until @ization/core is initialized, returns empty string.
izWeekday Pipe
temporalObj | izWeekday: format
temporalObj-Temporal.PlainDateorTemporal.PlainDateTimeinstance to localize.format- Format to use. Can be either one of strings'short' | 'medium' | 'long'or an object conforming toWeekdayFormatOptionsinterface.
Returns string that represents the input localized as a weekday. Until @ization/core is initialized, returns empty string.
Develop
Build
Run npm run build:temporal to build the package into the dist/temporal/ directory.
Unit tests
Run npm run test:temporal to execute the unit tests.
Linter
Run npm run lint:temporal 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.