@item-enonic-types/lib-time 1.0.3 → 1.1.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/LICENSE CHANGED
@@ -1,6 +1,6 @@
1
1
  MIT License
2
2
 
3
- Copyright (c) 2023 Item Consulting AS
3
+ Copyright (c) 2025 Item Consulting AS
4
4
 
5
5
  Permission is hereby granted, free of charge, to any person obtaining a copy
6
6
  of this software and associated documentation files (the "Software"), to deal
package/README.md CHANGED
@@ -3,7 +3,7 @@
3
3
  This library enables the usage of classes from the [`java.time`](https://docs.oracle.com/en/java/javase/11/docs/api/java.base/java/time/package-summary.html) package from Enonic XP application code.
4
4
  Other JavaScript-based time libraries like _Moment.js_ or _date-fns_ will negatively impact your bundle size and build time. This library is only a **thin TypeScript-wrapper** around the excellent core `java.time` library already present in your system!
5
5
 
6
- [![](https://jitpack.io/v/no.item/lib-xp-time.svg)](https://jitpack.io/#no.item/lib-xp-time)
6
+ [![](https://repo.itemtest.no/api/badge/latest/releases/no/item/lib-xp-time)](https://repo.itemtest.no/#/releases/no/item/lib-xp-time)
7
7
 
8
8
  <img src="https://github.com/ItemConsulting/lib-xp-time/raw/main/docs/icon.svg?sanitize=true" width="150">
9
9
 
@@ -15,11 +15,11 @@ To install this library you need to add a new dependency to your app's build.gra
15
15
 
16
16
  ```groovy
17
17
  repositories {
18
- maven { url 'https://jitpack.io' }
18
+ maven { url "https://repo.itemtest.no/releases" }
19
19
  }
20
20
 
21
21
  dependencies {
22
- include "no.item:lib-xp-time:1.0.2"
22
+ include "no.item:lib-xp-time:1.1.0"
23
23
  }
24
24
  ```
25
25
 
@@ -27,7 +27,7 @@ dependencies {
27
27
 
28
28
  To update the version of *enonic-types* in *package.json* using npm, run the following command:
29
29
  ```bash
30
- npm install --save-dev @item-enonic-types/lib-time
30
+ npm i -D @item-enonic-types/lib-time
31
31
  ```
32
32
 
33
33
  You can add the following changes to your *tsconfig.json* to get TypeScript-support.
@@ -123,22 +123,28 @@ The following classes is exposed/exported from `"/lib/time"`:
123
123
  * `ZoneId`
124
124
  * `ZoneOffset`
125
125
 
126
+ ## Deploying
127
+
126
128
  ### Building
127
129
 
128
- To build the project run the following code
130
+ To build the project, run the following command
129
131
 
130
132
  ```bash
131
- ./gradlew build
133
+ enonic project build
132
134
  ```
133
135
 
134
- ### Deploy locally
136
+ You will find the jar-file at _./build/libs/item.jar_
137
+
138
+ ### Deploying locally
135
139
 
136
- Deploy locally for testing purposes:
140
+ To deploy to a local sandbox, run the following command
137
141
 
138
142
  ```bash
139
- ./gradlew publishToMavenLocal
143
+ enonic project deploy
140
144
  ```
141
- ## Deploy to Jitpack
142
145
 
143
- Go to the [Jitpack page for lib-xp-time](https://jitpack.io/#no.item/lib-xp-time) to deploy from GitHub (after
144
- [creating a new versioned release](https://github.com/ItemConsulting/lib-xp-time/releases/new)).
146
+ ### Deploy to Maven
147
+
148
+ ```bash
149
+ ./gradlew publish -P com.enonic.xp.app.production=true
150
+ ```
@@ -37,6 +37,9 @@ export interface LocalDateTime {
37
37
  getNano(): number;
38
38
  getSecond(): number;
39
39
  getYear(): number;
40
+ isAfter(other: LocalDateTime): boolean;
41
+ isBefore(other: LocalDateTime): boolean;
42
+ isEqual(other: LocalDateTime): boolean;
40
43
  minusDays(days: number): LocalDateTime;
41
44
  minusHours(hours: number): LocalDateTime;
42
45
  minusMinutes(minutes: number): LocalDateTime;
package/local-date.d.ts CHANGED
@@ -38,6 +38,9 @@ export interface LocalDate {
38
38
  getYear(): number;
39
39
  hashCode(): number;
40
40
  toString(): string;
41
+ isAfter(other: LocalDate): boolean;
42
+ isBefore(other: LocalDate): boolean;
43
+ isEqual(other: LocalDate): boolean;
41
44
  isLeapYear(): boolean;
42
45
  lengthOfMonth(): number;
43
46
  lengthOfYear(): number;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@item-enonic-types/lib-time",
3
- "version": "1.0.3",
3
+ "version": "1.1.0",
4
4
  "description": "Type definitions for lib-time",
5
5
  "license": "MIT",
6
6
  "files": [
@@ -8,48 +8,32 @@
8
8
  "format/*.d.ts",
9
9
  "tsconfig.json"
10
10
  ],
11
- "scripts": {
12
- "build:server": "webpack --config webpack.server.config.js --color",
13
- "build": "run-p -c build:*",
14
- "dist:server": "cross-env NODE_ENV=production webpack --config webpack.server.config.js --color",
15
- "dist": "run-p -c dist:*",
16
- "lint": "eslint --fix 'src/**/*.ts'",
17
- "prepublishOnly": "tsc --declarationDir build/types --emitDeclarationOnly true --declaration true && cp -r ./build/types/src/main/resources/lib/time/* .",
18
- "postpublish": "rm ./*.d.ts && rm -r ./format"
19
- },
20
11
  "devDependencies": {
21
- "@babel/core": "^7.22.10",
22
- "@babel/plugin-proposal-class-properties": "^7.18.6",
23
- "@babel/preset-env": "^7.22.10",
24
- "@babel/register": "^7.22.5",
12
+ "@changesets/cli": "^2.27.11",
25
13
  "@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
- "cross-env": "^7.0.3",
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
- "npm-run-all": "^4.1.5",
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
- },
45
- "browserslist": [
46
- "extends browserslist-config-enonic"
47
- ],
48
- "engines": {
49
- "node": ">= 16.13.1 || >=18.0.0",
50
- "npm": ">= 8.1.2"
14
+ "@swc/core": "^1.10.7",
15
+ "@types/node": "^22.10.7",
16
+ "eslint": "^9.18.0",
17
+ "eslint-config-prettier": "^10.0.1",
18
+ "eslint-plugin-prettier": "^5.2.2",
19
+ "concurrently": "^9.1.2",
20
+ "glob": "^11.0.1",
21
+ "prettier": "^3.4.2",
22
+ "tsup": "^8.3.5",
23
+ "typescript": "^5.7.3",
24
+ "typescript-eslint": "^8.20.0"
51
25
  },
52
26
  "dependencies": {
53
27
  "@item-enonic-types/nashorn-env": "^0.0.2"
28
+ },
29
+ "scripts": {
30
+ "build": "node tsup/anyServerFiles.js && npx tsup -d build/resources/main",
31
+ "check": "concurrently -c auto -g --timings npm:check:types npm:lint",
32
+ "check:types": "node tsup/anyServerFiles.js && npx tsc --noEmit -p src/main/resources/tsconfig.json || exit 0",
33
+ "lint": "eslint --cache \"src/main/resources/**/*.ts\"",
34
+ "prepublishOnly": "tsc --project src/main/resources/tsconfig.json --declarationDir build/types --emitDeclarationOnly true --declaration true && cp -r ./build/types/* .",
35
+ "postpublish": "rm ./*.d.ts && rm -r ./format",
36
+ "release": "npm run build",
37
+ "versioning": "npx changeset version && npm i --package-lock-only && NEW_VERSION=$(node -p \"require('./package.json').version\") && sed -i \"s/version.*/version = ${NEW_VERSION}/\" gradle.properties"
54
38
  }
55
39
  }
package/tsconfig.json CHANGED
@@ -1,28 +1,18 @@
1
1
  {
2
- "compilerOptions": {
3
- "module": "commonjs",
4
- "moduleResolution": "node",
5
- "target": "es5",
6
- "sourceMap": false,
7
- "skipLibCheck": true,
8
- "allowJs": true,
9
- "noImplicitAny": true,
10
- "noImplicitReturns": true,
11
- "noImplicitThis": true,
12
- "strictNullChecks": true,
13
- "baseUrl": "./",
14
- "types": ["@item-enonic-types/nashorn-env"],
15
- "paths": {
16
- "/lib/xp/*": ["node_modules/@enonic-types/lib-*"],
17
- "/lib/*": [ "./node_modules/@item-enonic-types/lib-*" ,"./src/main/resources/lib/*"]
18
- },
19
- "declaration": true,
20
- "declarationDir": "build/types"
21
- },
2
+ "include": [
3
+ "**/*.ts"
4
+ ],
22
5
  "exclude": [
23
- "./build/*",
6
+ "**/*.d.ts",
7
+ "src/**/*.*", // Avoid Enonic XP source files
24
8
  ],
25
- "types": [
26
- "types"
27
- ]
9
+
10
+ "compilerOptions": {
11
+ "lib": [
12
+ "es2023" // string.replaceAll
13
+ ],
14
+ "types": [
15
+ "node"
16
+ ],
17
+ },
28
18
  }
@@ -30,6 +30,9 @@ export interface ZonedDateTime {
30
30
  getOffset(): ZoneOffset;
31
31
  getSecond(): number;
32
32
  getYear(): number;
33
+ isAfter(other: ZonedDateTime): boolean;
34
+ isBefore(other: ZonedDateTime): boolean;
35
+ isEqual(other: ZonedDateTime): boolean;
33
36
  getZone(): ZoneId;
34
37
  hashCode(): number;
35
38
  minusDays(days: number): ZonedDateTime;