@ngnz/dayjs
TypeScript icon, indicating that this package has built-in type declarations

0.0.4 • Public • Published

@ngnz/dayjs

Immutable Date-Time utils allow you to display Date like 1 minute ago.

installation

Install npm package with the following commande:

$ npm install @ngzn/dayjs

And add import inside app.module.ts or desired module.

import { BrowserModule } from '@angular/platform-browser';
import { NgModule } from '@angular/core';

import { AppComponent } from './app.component';
// import for @ngnz/dayjs
import { DayjsModule, DAYJS_LOCAL_PRESSET } from '@ngnz/dayjs';
import 'dayjs/locale/en'; // import desired language
// optionnal config for @ngnz/dayjs
const localDayjsPressetFactory = () => {
  // add logic to get user selected language
  return 'en'
};

@NgModule({
  declarations: [AppComponent],
  imports: [
    BrowserModule,
    // add module inside your Angular application module
    DayjsModuleModule 
  ],
  providers: [
    // optionnal config to change language pressets
    {
      provide: DAYJS_LOCAL_PRESSET,
      useFactory() {
        return localDayjsPressetFactory()
      }
    }
  ],
  bootstrap: [AppComponent],
})
export class AppModule {}

Usage

Useing Angular Pipe inside Angular application.

{{'01/01/2021'|dayjs: 'formNow'}}

Only Function Usage

This feature is exporetable without Angular wrapping to allow using inside other projet.

// import function
import { dayjsFunction } from '@ngnz/dayjs';

// user copy function logic
const value = '01/01/2021';
const result = new dayjsFunction('fr').transform(value, 'fromNow', null, true);

Readme

Keywords

none

Package Sidebar

Install

npm i @ngnz/dayjs

Weekly Downloads

5

Version

0.0.4

License

none

Unpacked Size

78.3 kB

Total Files

29

Last publish

Collaborators

  • fazio