@js-joda/core 5.7.0 → 6.0.1
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 +0 -2
- package/dist/js-joda.cjs.js +204 -227
- package/dist/js-joda.cjs.js.map +1 -1
- package/dist/js-joda.esm.js +204 -227
- package/dist/js-joda.esm.js.map +1 -1
- package/dist/js-joda.js +204 -227
- package/dist/js-joda.js.map +1 -1
- package/dist/js-joda.min.js +2 -2
- package/package.json +2 -3
- package/src/MathUtil.js +1 -5
- package/src/nativeJs.js +2 -8
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@js-joda/core",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "6.0.1",
|
|
4
4
|
"description": "a date and time library for javascript",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -31,7 +31,6 @@
|
|
|
31
31
|
"test": "NODE_ENV=test npx mocha --timeout 5000 --require @babel/register ./test/*Test_mochaOnly.js ./test/*Test.js ./test/**/*Test.js ./test/**/**/*Test.js",
|
|
32
32
|
"test-coverage": "NODE_ENV=test COVERAGE=1 npx nyc --report-dir=build/coverage --reporter=lcov --reporter html npx mocha --timeout 5000 --require @babel/register --reporter progress ./test/*Test.js ./test/**/*Test.js ./test/**/**/*Test.js",
|
|
33
33
|
"test-browser": "npx karma start --reporters=dots --single-run",
|
|
34
|
-
"test-saucelabs": "npx karma start --reporters=\"dots,saucelabs\" --browsers=\"sl_chrome,sl_firefox\" --single-run=true",
|
|
35
34
|
"test-ci": "npm run build-dist && npm run test && npm run test-browser && npm run test-ts-definitions && npm run test-coverage",
|
|
36
35
|
"test-ts-definitions": "TS_NODE_PROJECT='../../shared/ts-test-config.json' NODE_ENV=test mocha --timeout 5000 --require ts-node/register ./test/typescript_definitions/*.ts",
|
|
37
36
|
"build-dist": "npx rollup -c rollup.config.js",
|
|
@@ -48,5 +47,5 @@
|
|
|
48
47
|
"sourceMap": false,
|
|
49
48
|
"instrument": false
|
|
50
49
|
},
|
|
51
|
-
"gitHead": "
|
|
50
|
+
"gitHead": "a7f1bec40afb1e84ffc0ce2d88d72d690fe72f6a"
|
|
52
51
|
}
|
package/src/MathUtil.js
CHANGED
|
@@ -168,11 +168,7 @@ export class MathUtil {
|
|
|
168
168
|
if (isNaN(value)) {
|
|
169
169
|
throw new ArithmeticException('Invalid int value, using NaN as argument');
|
|
170
170
|
}
|
|
171
|
-
if (Number.isInteger) {
|
|
172
|
-
if (!Number.isInteger(Number(value))) {
|
|
173
|
-
throw new ArithmeticException(`Invalid value: '${value}' is a float`);
|
|
174
|
-
}
|
|
175
|
-
} else if ((value % 1) !== 0) { // IE11 does not support Number.isInteger
|
|
171
|
+
if (!Number.isInteger(Number(value))) {
|
|
176
172
|
throw new ArithmeticException(`Invalid value: '${value}' is a float`);
|
|
177
173
|
}
|
|
178
174
|
if (value > MAX_SAFE_INTEGER || value < MIN_SAFE_INTEGER) {
|
package/src/nativeJs.js
CHANGED
|
@@ -4,22 +4,16 @@
|
|
|
4
4
|
*/
|
|
5
5
|
|
|
6
6
|
import { requireNonNull } from './assert';
|
|
7
|
-
import { IllegalArgumentException } from './errors';
|
|
8
7
|
import { Instant, ZoneId } from './js-joda';
|
|
9
8
|
|
|
10
9
|
/**
|
|
11
10
|
* Creates ZonedDateTime from a javascript Date or a moment instance.
|
|
12
|
-
* @param {
|
|
11
|
+
* @param {string} date - a javascript Date or a moment instance
|
|
13
12
|
* @param {ZoneId} [zone = ZoneId.systemDefault()] - the zone of the returned ZonedDateTime, defaults to ZoneId.systemDefault()
|
|
14
13
|
* @returns {ZonedDateTime}
|
|
15
14
|
*/
|
|
16
15
|
export function nativeJs(date, zone = ZoneId.systemDefault()) {
|
|
17
16
|
requireNonNull(date, 'date');
|
|
18
17
|
requireNonNull(zone, 'zone');
|
|
19
|
-
|
|
20
|
-
return Instant.ofEpochMilli(date.getTime()).atZone(zone);
|
|
21
|
-
} else if(typeof date.toDate === 'function' && date.toDate() instanceof Date) {
|
|
22
|
-
return Instant.ofEpochMilli(date.toDate().getTime()).atZone(zone);
|
|
23
|
-
}
|
|
24
|
-
throw new IllegalArgumentException('date must be a javascript Date or a moment instance');
|
|
18
|
+
return Instant.ofEpochMilli(date.valueOf()).atZone(zone);
|
|
25
19
|
}
|