@fundamental-ngx/datetime-adapter 0.62.2-rc.8 → 0.62.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +48 -4
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -8,7 +8,7 @@
|
|
|
8
8
|
|
|
9
9
|
Date/time adapter based on [Day.js](https://day.js.org/) for Fundamental NGX date and time components (Date Picker, Time Picker, DateTime Picker, etc.).
|
|
10
10
|
|
|
11
|
-
|
|
11
|
+
Fundamental NGX date components rely on the `DatetimeAdapter` abstraction from `@fundamental-ngx/core/datetime`. By default they use the built-in `FdDatetimeAdapter` (native `Date`). This package provides `DayjsDatetimeAdapter` as an alternative, which adds reliable locale-aware parsing and formatting via Day.js.
|
|
12
12
|
|
|
13
13
|
## Installation
|
|
14
14
|
|
|
@@ -18,11 +18,55 @@ npm install @fundamental-ngx/datetime-adapter dayjs
|
|
|
18
18
|
|
|
19
19
|
## Usage
|
|
20
20
|
|
|
21
|
+
Import `DayjsDatetimeAdapterModule` in the module or standalone component that hosts your date/time components:
|
|
22
|
+
|
|
23
|
+
```typescript
|
|
24
|
+
// app.config.ts
|
|
25
|
+
import { ApplicationConfig, importProvidersFrom } from '@angular/core';
|
|
26
|
+
import { DayjsDatetimeAdapterModule } from '@fundamental-ngx/datetime-adapter';
|
|
27
|
+
|
|
28
|
+
export const appConfig: ApplicationConfig = {
|
|
29
|
+
providers: [importProvidersFrom(DayjsDatetimeAdapterModule)]
|
|
30
|
+
};
|
|
31
|
+
```
|
|
32
|
+
|
|
33
|
+
Or import it directly in a standalone component:
|
|
34
|
+
|
|
35
|
+
```typescript
|
|
36
|
+
import { Component } from '@angular/core';
|
|
37
|
+
import { DatePickerComponent } from '@fundamental-ngx/core/date-picker';
|
|
38
|
+
import { DayjsDatetimeAdapterModule } from '@fundamental-ngx/datetime-adapter';
|
|
39
|
+
import type { Dayjs } from 'dayjs';
|
|
40
|
+
|
|
41
|
+
@Component({
|
|
42
|
+
selector: 'app-date-example',
|
|
43
|
+
imports: [DatePickerComponent, DayjsDatetimeAdapterModule],
|
|
44
|
+
template: `<fd-date-picker [(ngModel)]="date" />`
|
|
45
|
+
})
|
|
46
|
+
export class DateExampleComponent {
|
|
47
|
+
date: Dayjs | null = null;
|
|
48
|
+
}
|
|
49
|
+
```
|
|
50
|
+
|
|
51
|
+
### Locale support
|
|
52
|
+
|
|
53
|
+
Day.js locale plugins are loaded separately. Import the locale before bootstrapping:
|
|
54
|
+
|
|
55
|
+
```typescript
|
|
56
|
+
import 'dayjs/locale/de';
|
|
57
|
+
import dayjs from 'dayjs';
|
|
58
|
+
|
|
59
|
+
dayjs.locale('de');
|
|
60
|
+
```
|
|
61
|
+
|
|
62
|
+
### Strict parsing and UTC mode
|
|
63
|
+
|
|
64
|
+
Configure the adapter via `DAYJS_DATE_TIME_ADAPTER_OPTIONS`:
|
|
65
|
+
|
|
21
66
|
```typescript
|
|
22
|
-
import {
|
|
67
|
+
import { DAYJS_DATE_TIME_ADAPTER_OPTIONS } from '@fundamental-ngx/datetime-adapter';
|
|
23
68
|
|
|
24
|
-
|
|
25
|
-
provideDatetimeAdapter();
|
|
69
|
+
providers: [{ provide: DAYJS_DATE_TIME_ADAPTER_OPTIONS, useValue: { strict: true, useUtc: false } }];
|
|
26
70
|
```
|
|
27
71
|
|
|
28
72
|
See the [documentation](https://sap.github.io/fundamental-ngx) for full configuration and format customization options.
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@fundamental-ngx/datetime-adapter",
|
|
3
|
-
"version": "0.62.2
|
|
3
|
+
"version": "0.62.2",
|
|
4
4
|
"description": "Datetime adapter for SAP Fundamentals, based on Day.js package",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"homepage": "https://sap.github.io/fundamental-ngx",
|
|
@@ -9,7 +9,7 @@
|
|
|
9
9
|
"url": "git+https://github.com/SAP/fundamental-ngx.git"
|
|
10
10
|
},
|
|
11
11
|
"peerDependencies": {
|
|
12
|
-
"@fundamental-ngx/core": "0.62.2
|
|
12
|
+
"@fundamental-ngx/core": "0.62.2",
|
|
13
13
|
"dayjs": "^1.11.0"
|
|
14
14
|
},
|
|
15
15
|
"dependencies": {
|