@item-enonic-types/lib-time 1.2.0 → 1.3.0
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 +28 -3
- package/local-date-time.d.ts +2 -0
- package/package.json +13 -13
- package/util.d.ts +1 -1
- package/zoned-date-time.d.ts +2 -0
package/README.md
CHANGED
|
@@ -19,7 +19,7 @@ repositories {
|
|
|
19
19
|
}
|
|
20
20
|
|
|
21
21
|
dependencies {
|
|
22
|
-
include "no.item:lib-xp-time:1.
|
|
22
|
+
include "no.item:lib-xp-time:1.3.0"
|
|
23
23
|
}
|
|
24
24
|
```
|
|
25
25
|
|
|
@@ -107,11 +107,32 @@ const time = today.format(formatter);
|
|
|
107
107
|
// time = "tirsdag 21. februar 2023 12:15:30"
|
|
108
108
|
```
|
|
109
109
|
|
|
110
|
+
*Example of using hte `LanguageRange` utility to find the preferred locale among the ones supported by the application.*
|
|
111
|
+
|
|
112
|
+
```typescript
|
|
113
|
+
import { LanguageRange, Locale } from "/lib/time";
|
|
114
|
+
import { getSupportedLocales } from "/lib/xp/i18n";
|
|
115
|
+
import type { Request, Response } from "@enonic-types/core";
|
|
116
|
+
|
|
117
|
+
export function get(req: Request): Response {
|
|
118
|
+
const languageRange = LanguageRange.parse(req.headers["Accept-Language"]);
|
|
119
|
+
|
|
120
|
+
const locale: string = Locale.filterTags(
|
|
121
|
+
languageRange,
|
|
122
|
+
getSupportedLocales(["i18n/phrases"])
|
|
123
|
+
)[0];
|
|
124
|
+
|
|
125
|
+
...
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
```
|
|
129
|
+
|
|
110
130
|
### Constants exposed from `"/lib/time"`
|
|
111
131
|
The following classes is exposed/exported from `"/lib/time"`:
|
|
112
132
|
* `DateTimeFormatter`
|
|
113
133
|
* `DayOfWeek`
|
|
114
134
|
* `Instant`
|
|
135
|
+
* `LanguageRange`
|
|
115
136
|
* `LocalDate`
|
|
116
137
|
* `LocalDateTime`
|
|
117
138
|
* `Locale`
|
|
@@ -133,8 +154,6 @@ To build the project, run the following command
|
|
|
133
154
|
enonic project build
|
|
134
155
|
```
|
|
135
156
|
|
|
136
|
-
You will find the jar-file at _./build/libs/item.jar_
|
|
137
|
-
|
|
138
157
|
### Deploying locally
|
|
139
158
|
|
|
140
159
|
To deploy to a local sandbox, run the following command
|
|
@@ -148,3 +167,9 @@ enonic project deploy
|
|
|
148
167
|
```bash
|
|
149
168
|
./gradlew publish -P com.enonic.xp.app.production=true
|
|
150
169
|
```
|
|
170
|
+
|
|
171
|
+
### Deploy to npm
|
|
172
|
+
|
|
173
|
+
```bash
|
|
174
|
+
npm publish
|
|
175
|
+
```
|
package/local-date-time.d.ts
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@item-enonic-types/lib-time",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.3.0",
|
|
4
4
|
"description": "Type definitions for lib-time",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"files": [
|
|
@@ -9,19 +9,19 @@
|
|
|
9
9
|
"tsconfig.json"
|
|
10
10
|
],
|
|
11
11
|
"devDependencies": {
|
|
12
|
-
"@changesets/cli": "^2.
|
|
12
|
+
"@changesets/cli": "^2.29.8",
|
|
13
13
|
"@item-enonic-types/lib-testing": "^7.13.0",
|
|
14
|
-
"@swc/core": "^1.
|
|
15
|
-
"@types/node": "^
|
|
16
|
-
"eslint": "^9.
|
|
17
|
-
"eslint-config-prettier": "^10.
|
|
18
|
-
"eslint-plugin-prettier": "^5.
|
|
19
|
-
"concurrently": "^9.1
|
|
20
|
-
"glob": "^
|
|
21
|
-
"prettier": "^3.4
|
|
22
|
-
"tsup": "^8.
|
|
23
|
-
"typescript": "^5.
|
|
24
|
-
"typescript-eslint": "^8.
|
|
14
|
+
"@swc/core": "^1.15.4",
|
|
15
|
+
"@types/node": "^25.0.1",
|
|
16
|
+
"eslint": "^9.39.2",
|
|
17
|
+
"eslint-config-prettier": "^10.1.8",
|
|
18
|
+
"eslint-plugin-prettier": "^5.5.4",
|
|
19
|
+
"concurrently": "^9.2.1",
|
|
20
|
+
"glob": "^13.0.0",
|
|
21
|
+
"prettier": "^3.7.4",
|
|
22
|
+
"tsup": "^8.5.1",
|
|
23
|
+
"typescript": "^5.9.3",
|
|
24
|
+
"typescript-eslint": "^8.49.0"
|
|
25
25
|
},
|
|
26
26
|
"dependencies": {
|
|
27
27
|
"@item-enonic-types/nashorn-env": "^0.0.2"
|
package/util.d.ts
CHANGED
|
@@ -32,7 +32,7 @@ export interface LocaleConstructor {
|
|
|
32
32
|
UNICODE_LOCALE_EXTENSION: Locale;
|
|
33
33
|
US: Locale;
|
|
34
34
|
filter(priorityList: LanguageRange[], locales: Locale[]): Locale[];
|
|
35
|
-
filterTags(priorityList: LanguageRange[], tags: string[]):
|
|
35
|
+
filterTags(priorityList: LanguageRange[], tags: string[]): string[];
|
|
36
36
|
forLanguageTag(languageTag: string): Locale;
|
|
37
37
|
getAvailableLocales(): Locale[];
|
|
38
38
|
getDefault(): Locale;
|