You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The project exposes an abstraction interface over [luxon](https://moment.github.io/luxon/), [date-fns v2](https://github.com/date-fns/date-fns), [dayjs](https://github.com/iamkun/dayjs) and [moment](https://momentjs.com/).
15
-
It allows you to build any UI date or time components, while utilizing the same date management library in use within your user's project.
15
+
It allows you to build any UI date or time components while utilizing the same date management library in use within your user's project.
16
16
17
17
It simplifies timezone management, allows your code to return the exact same type that your user expects and works with specific calendar systems (e.g. [Jalali calendar](https://en.wikipedia.org/wiki/Jalali_calendar))
18
18
@@ -24,7 +24,7 @@ It simplifies timezone management, allows your code to return the exact same typ
If you are a library author that exposes date/time management utils or controls you may want to use date-io to interop with the most popular libraries. Here are some instructions of how to use date-fns as an adapter.
230
+
If you are a library author that exposes date/time management utils or controls you may want to use date-io to interop with the most popular libraries. Here are some instructions on how to use date-fns as an adapter.
229
231
230
232
#### 1. Install the bindings
231
233
232
-
First of all it is required to provide the adapters for your users. We do not recommend to install the date-io directly by the end users, cause it may be easy to mismatch the version. The better way will be to reexport them.
234
+
First of all, it is required to provide the adapters for your users. We do not recommend installing the date-io directly by the end users, cause it may be easy to mismatch the version. The better way will be to reexport them.
233
235
234
236
Firstly install all the adapters you want to support and lock the version.
235
237
@@ -254,18 +256,46 @@ Firstly install all the adapters you want to support and lock the version.
254
256
export { default } from"@date-io/date-fns";
255
257
```
256
258
257
-
You can also manually extend the adapter if you need to. Create a custom interface:
259
+
### Overriding behavior
260
+
261
+
It is possible to change or extend the behavior of any adapter by simply inheriting and overriding the base class of utils while saving the same interface.
262
+
263
+
Let's say you want to override `getYear` to always return 2007 and `getWeekdays` to contain only 2 weekends (let's admit that this is what we all desire) you can do the following:
Note: that you will need to do this with every adapter you want to support to be in sync.
275
+
276
+
### Extending behavior
277
+
278
+
It is possible also to add custom functionality to the adapter, in case the author of date-io doesn't want to add it. To do this create **your custom interface that extends IUtils** and inherit your adapters both from the base adapter and your custom interface.
And extend date-io classes implementing your custom interface:
296
+
### Build system
297
+
298
+
In some build systems (hello babel) it may be impossible to extend the methods because they are defined as class properties. While it should be standardized already there are still some issues with it. In this case you can use the following workaround:
Register it using your library context. It may be react context, dependency injection container or any other tool that allow user to register the used library **1 time**.
327
+
Register it using your library context. It may be react context, dependency injection container or any other tool that allows the user to register the used library **1 time**.
0 commit comments