@item-enonic-types/lib-time 1.0.0 → 1.0.3

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:1.0.0"
22
+ include "no.item:lib-xp-time:1.0.2"
23
23
  }
24
24
  ```
25
25
 
@@ -77,13 +77,25 @@ const time = fiftyMinutesAgo.toLocalTime();
77
77
  ```typescript
78
78
  import { formatDate } from "/lib/time";
79
79
 
80
- const today = t.formatDate({
80
+ const today = formatDate({
81
81
  date: "2023-02-21",
82
82
  pattern: "dd-MM-yyyy",
83
83
  locale: "no"
84
84
  });
85
85
  // today = "21-02-2023"
86
86
  ```
87
+ *Use `formatDate()` with a given timezoneId*
88
+ ```typescript
89
+ import { formatDate } from "/lib/time";
90
+
91
+ const today = formatDate({
92
+ date: "2023-02-21",
93
+ pattern: "dd-MM-yyyy",
94
+ locale: "no",
95
+ timezoneId: "Europe/Oslo"
96
+ });
97
+ // today = "21-02-2023"
98
+ ```
87
99
 
88
100
  *Example of using `Locale` in formatting a `LocalDateTime` and get a normalized timestamp :*
89
101
  ```typescript
package/day-of-week.d.ts CHANGED
@@ -6,8 +6,12 @@ export declare const DayOfWeek: DayOfWeekConstructor;
6
6
  export type WeekDayNumber = 1 | 2 | 3 | 4 | 5 | 6 | 7;
7
7
  export interface DayOfWeekConstructor {
8
8
  of(dayOfWeek: WeekDayNumber): DayOfWeek;
9
+ valueOf(name: string): DayOfWeek;
10
+ values(): DayOfWeek[];
9
11
  }
10
12
  export interface DayOfWeek {
11
13
  getValue(): WeekDayNumber;
14
+ minus(days: number): DayOfWeek;
15
+ plus(days: number): DayOfWeek;
12
16
  toString(): string;
13
17
  }
package/index.d.ts CHANGED
@@ -19,15 +19,17 @@ export { ZoneOffset } from "/lib/time/zone-offset";
19
19
  * @param pattern The shape of the output string
20
20
  * @param locale The locale of the country you are formatting to
21
21
  */
22
- export declare function formatDate({ date, pattern, locale }: FormatDateParams): string;
23
- export declare function formatDate({ date, pattern, locale }: FormatDateParamsAllowNullable): string | undefined;
22
+ export declare function formatDate({ date, pattern, locale, timezoneId }: FormatDateParams): string;
23
+ export declare function formatDate({ date, pattern, locale, timezoneId }: FormatDateParamsAllowNullable): string | undefined;
24
24
  export interface FormatDateParams {
25
25
  date: string | Date;
26
26
  pattern: string;
27
27
  locale?: string | undefined;
28
+ timezoneId?: string | undefined;
28
29
  }
29
30
  export interface FormatDateParamsAllowNullable {
30
31
  date: string | Date | undefined | null;
31
32
  pattern: string;
32
33
  locale?: string | undefined;
34
+ timezoneId?: string | undefined;
33
35
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@item-enonic-types/lib-time",
3
- "version": "1.0.0",
3
+ "version": "1.0.3",
4
4
  "description": "Type definitions for lib-time",
5
5
  "license": "MIT",
6
6
  "files": [
@@ -14,39 +14,42 @@
14
14
  "dist:server": "cross-env NODE_ENV=production webpack --config webpack.server.config.js --color",
15
15
  "dist": "run-p -c dist:*",
16
16
  "lint": "eslint --fix 'src/**/*.ts'",
17
- "prepublishOnly": "tsc --declarationDir build/types --emitDeclarationOnly true --declaration true && cp -r ./build/types/* .",
17
+ "prepublishOnly": "tsc --declarationDir build/types --emitDeclarationOnly true --declaration true && cp -r ./build/types/src/main/resources/lib/time/* .",
18
18
  "postpublish": "rm ./*.d.ts && rm -r ./format"
19
19
  },
20
20
  "devDependencies": {
21
- "@babel/core": "^7.21.0",
21
+ "@babel/core": "^7.22.10",
22
22
  "@babel/plugin-proposal-class-properties": "^7.18.6",
23
- "@babel/preset-env": "^7.20.2",
24
- "@babel/register": "^7.21.0",
25
- "@item-enonic-types/lib-testing": "^7.11.3",
26
- "@types/node": "^18.14.1",
27
- "@typescript-eslint/eslint-plugin": "^5.53.0",
28
- "@typescript-eslint/parser": "^5.53.0",
29
- "babel-loader": "^9.1.2",
30
- "browserslist": "^4.21.5",
31
- "browserslist-config-enonic": "^1.0.7",
23
+ "@babel/preset-env": "^7.22.10",
24
+ "@babel/register": "^7.22.5",
25
+ "@item-enonic-types/lib-testing": "^7.13.0",
26
+ "@types/node": "^20.5.3",
27
+ "@typescript-eslint/eslint-plugin": "^6.4.1",
28
+ "@typescript-eslint/parser": "^6.4.1",
29
+ "babel-loader": "^9.1.3",
30
+ "browserslist": "^4.21.10",
31
+ "browserslist-config-enonic": "^1.0.8",
32
32
  "cross-env": "^7.0.3",
33
- "eslint": "^8.34.0",
34
- "eslint-config-prettier": "^8.6.0",
35
- "eslint-plugin-prettier": "^4.2.1",
36
- "glob": "^8.1.0",
33
+ "eslint": "^8.47.0",
34
+ "eslint-config-prettier": "^9.0.0",
35
+ "eslint-plugin-prettier": "^5.0.0",
36
+ "glob": "^10.3.3",
37
37
  "npm-run-all": "^4.1.5",
38
- "prettier": "^2.8.4",
39
- "ramda": "^0.28.0",
40
- "ts-loader": "^9.4.2",
41
- "typescript": "^4.9.5",
42
- "webpack": "^5.75.0",
43
- "webpack-cli": "^5.0.1"
38
+ "prettier": "^3.0.2",
39
+ "ramda": "^0.29.0",
40
+ "ts-loader": "^9.4.4",
41
+ "typescript": "^5.1.6",
42
+ "webpack": "^5.88.2",
43
+ "webpack-cli": "^5.1.4"
44
44
  },
45
45
  "browserslist": [
46
46
  "extends browserslist-config-enonic"
47
47
  ],
48
48
  "engines": {
49
- "node": ">= 16.13.1",
49
+ "node": ">= 16.13.1 || >=18.0.0",
50
50
  "npm": ">= 8.1.2"
51
+ },
52
+ "dependencies": {
53
+ "@item-enonic-types/nashorn-env": "^0.0.2"
51
54
  }
52
55
  }
package/tsconfig.json CHANGED
@@ -4,12 +4,14 @@
4
4
  "moduleResolution": "node",
5
5
  "target": "es5",
6
6
  "sourceMap": false,
7
+ "skipLibCheck": true,
7
8
  "allowJs": true,
8
9
  "noImplicitAny": true,
9
10
  "noImplicitReturns": true,
10
11
  "noImplicitThis": true,
11
12
  "strictNullChecks": true,
12
13
  "baseUrl": "./",
14
+ "types": ["@item-enonic-types/nashorn-env"],
13
15
  "paths": {
14
16
  "/lib/xp/*": ["node_modules/@enonic-types/lib-*"],
15
17
  "/lib/*": [ "./node_modules/@item-enonic-types/lib-*" ,"./src/main/resources/lib/*"]
@@ -1,2 +0,0 @@
1
- declare const _exports: any;
2
- export = _exports;