my-timezone 1.15.3 → 1.15.5

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.
Files changed (2) hide show
  1. package/dist/MyTimezone.js +8 -10
  2. package/package.json +10 -7
@@ -77,18 +77,16 @@ export class MyTimezone {
77
77
  }
78
78
  parseCoordinates(coordinates) {
79
79
  var _a;
80
- const coordinatesRegex = new RegExp('([-?\\W\\d\\.]+,)?(?<longitude>[-?\\W\\d\\.]+)');
80
+ const coordinatesRegex = /^(?:\s*[+-]?(?:\d+(?:\.\d*)?|\.\d+)\s*,)?\s*(?<longitude>[+-]?(?:\d+(?:\.\d*)?|\.\d+))\s*$/;
81
81
  const parsedRegex = coordinatesRegex.exec(coordinates);
82
- if ((_a = parsedRegex === null || parsedRegex === void 0 ? void 0 : parsedRegex.groups) === null || _a === void 0 ? void 0 : _a.longitude) {
83
- try {
84
- const longitude = parseFloat(parsedRegex.groups.longitude);
85
- return { longitude };
86
- }
87
- catch (_b) {
88
- throw new Error(`Invalid coordinates: "${coordinates}"`);
89
- }
82
+ if (!((_a = parsedRegex === null || parsedRegex === void 0 ? void 0 : parsedRegex.groups) === null || _a === void 0 ? void 0 : _a.longitude)) {
83
+ throw new Error(`No coordinates parsed: "${coordinates}"`);
84
+ }
85
+ const longitude = parseFloat(parsedRegex.groups.longitude);
86
+ if (Number.isNaN(longitude)) {
87
+ throw new Error(`Invalid coordinates: "${coordinates}"`);
90
88
  }
91
- throw new Error(`No coordinates parsed: "${coordinates}"`);
89
+ return { longitude };
92
90
  }
93
91
  parseDate(date) {
94
92
  const isoString = date.toISOString();
package/package.json CHANGED
@@ -3,14 +3,14 @@
3
3
  "bin": "dist/cli.js",
4
4
  "dependencies": {
5
5
  "commander": "14.0.3",
6
- "ntpclient": "1.16.1"
6
+ "ntpclient": "1.16.3"
7
7
  },
8
8
  "description": "Calculate the true solar time at any geographic location.",
9
9
  "devDependencies": {
10
- "nock": "14.0.11",
11
- "tsx": "4.21.0",
12
- "typescript": "6.0.2",
13
- "vitest": "4.1.2"
10
+ "nock": "14.0.15",
11
+ "tsx": "4.22.0",
12
+ "typescript": "6.0.3",
13
+ "vitest": "4.1.6"
14
14
  },
15
15
  "engines": {
16
16
  "node": ">= 21"
@@ -23,7 +23,10 @@
23
23
  "module": "dist/index.js",
24
24
  "name": "my-timezone",
25
25
  "readme": "https://github.com/ffflorian/node-packages#readme",
26
- "repository": "https://github.com/ffflorian/node-packages.git",
26
+ "repository": {
27
+ "type": "git",
28
+ "url": "git+https://github.com/ffflorian/node-packages.git"
29
+ },
27
30
  "scripts": {
28
31
  "build": "tsc -p tsconfig.build.json",
29
32
  "clean": "rm -rf dist",
@@ -32,5 +35,5 @@
32
35
  "test": "vitest run"
33
36
  },
34
37
  "type": "module",
35
- "version": "1.15.3"
38
+ "version": "1.15.5"
36
39
  }