@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 CHANGED
@@ -19,7 +19,7 @@ repositories {
19
19
  }
20
20
 
21
21
  dependencies {
22
- include "no.item:lib-xp-time:0.1.0"
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 inThreeWeeks = today.plusWeeks(3);
58
- const dateStr = inThreeWeeks.format(DateTimeFormatter.ofPattern("dd-MM-yyyy hh:mm:ss"));
59
- // dateStr = "14-03-2023 12:15:30"
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
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@item-enonic-types/lib-time",
3
- "version": "0.1.2",
3
+ "version": "1.0.0",
4
4
  "description": "Type definitions for lib-time",
5
5
  "license": "MIT",
6
6
  "files": [
package/tsconfig.json CHANGED
@@ -17,9 +17,6 @@
17
17
  "declaration": true,
18
18
  "declarationDir": "build/types"
19
19
  },
20
- "include": [
21
- "./src/main/resources/**/*"
22
- ],
23
20
  "exclude": [
24
21
  "./build/*",
25
22
  ],
@@ -0,0 +1,2 @@
1
+ declare const _exports: any;
2
+ export = _exports;