@item-enonic-types/lib-time 0.1.2 → 1.0.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 +16 -4
- package/package.json +1 -1
- package/tsconfig.json +0 -3
- package/webpack.server.config.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:
|
|
22
|
+
include "no.item:lib-xp-time:1.0.0"
|
|
23
23
|
}
|
|
24
24
|
```
|
|
25
25
|
|
|
@@ -54,9 +54,11 @@ You can import `java.time` and `java.time.format` classes from `"/lib/time"`.
|
|
|
54
54
|
import { LocalDateTime, DateTimeFormatter } from "/lib/time";
|
|
55
55
|
|
|
56
56
|
const today = LocalDateTime.parse("2023-02-21T12:15:30");
|
|
57
|
-
const
|
|
58
|
-
const
|
|
59
|
-
|
|
57
|
+
const formatter = DateTimeFormatter.ofPattern("dd.MM hh:mm")
|
|
58
|
+
const inThreeWeeksStr = today
|
|
59
|
+
.plusWeeks(3)
|
|
60
|
+
.format(formatter);
|
|
61
|
+
// inThreeWeeksStr = "14.03 12:15"
|
|
60
62
|
```
|
|
61
63
|
|
|
62
64
|
*Example of doing time math using a `ZonedDateTime`:*
|
|
@@ -83,6 +85,16 @@ const today = t.formatDate({
|
|
|
83
85
|
// today = "21-02-2023"
|
|
84
86
|
```
|
|
85
87
|
|
|
88
|
+
*Example of using `Locale` in formatting a `LocalDateTime` and get a normalized timestamp :*
|
|
89
|
+
```typescript
|
|
90
|
+
import { LocalDateTime, DateTimeFormatter, Locale } from "/lib/time";
|
|
91
|
+
|
|
92
|
+
const today = LocalDateTime.parse("2023-02-21T12:15:30");
|
|
93
|
+
const formatter = DateTimeFormatter.ofPattern("EEEE d. MMMM yyyy hh:mm:ss", new Locale("no"));
|
|
94
|
+
const time = today.format(formatter);
|
|
95
|
+
// time = "tirsdag 21. februar 2023 12:15:30"
|
|
96
|
+
```
|
|
97
|
+
|
|
86
98
|
### Constants exposed from `"/lib/time"`
|
|
87
99
|
The following classes is exposed/exported from `"/lib/time"`:
|
|
88
100
|
* `DateTimeFormatter`
|
package/package.json
CHANGED
package/tsconfig.json
CHANGED