ngx-material-luxon
TypeScript icon, indicating that this package has built-in type declarations

1.1.1 • Public • Published

ngx-material-luxon


npm Downloads MIT commitizen PRs styled with prettier All Contributors

Luxon Date Adapter for Angular Material

Credits for most of this go to crisbeto in https://github.com/angular/components/pull/14681.

Original PR has been left unmerged due to https://github.com/angular/components/pull/14681#issuecomment-457685311

Features

  • Drop an import in your @NgModule and enjoy Luxon DateTime objects

Table of Contents

Installation

NPM

npm install ngx-material-luxon --save

Yarn

yarn add ngx-material-luxon

Usage

import { MatLuxonDateModule } from 'ngx-material-luxon';

@NgModule({
  imports: [MatLuxonDateModule]
})
class AppModule { }

FAQ

Specifying the first day of the week

Luxon does not support have built-in support for returning the first day of the week of the current locale. However, the library allows overriding it via an optional hook.

Example:

const firstDayOfWeek = (locale: string) => {
  // 0 = Sunday, 1 = Monday, etc
  return 1;
}

@NgModule({
  imports: [LuxonDateModule],
  providers: [
    {
      provide: MAT_LUXON_DATE_ADAPTER_OPTIONS,
      useValue: { firstDayOfWeek },
    },
  ],
})

For most apps, a simple return like above is probably fine. For more complex apps, you can use a third party library like: weekstart

Contributors

Thanks goes to these wonderful people (emoji key):


Andrei Alecu

📖 🚇 💻 📆

Daniel Harvey

🐛 💻

Kristiyan Kostadinov

💻 ⚠️ 🤔

This project follows the all-contributors specification. Contributions of any kind welcome!

Package Sidebar

Install

npm i ngx-material-luxon

Weekly Downloads

519

Version

1.1.1

License

MIT

Unpacked Size

179 kB

Total Files

20

Last publish

Collaborators

  • andrei.alecu