@js-joda/core 5.5.0 → 5.5.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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@js-joda/core",
3
- "version": "5.5.0",
3
+ "version": "5.5.1",
4
4
  "description": "a date and time library for javascript",
5
5
  "repository": {
6
6
  "type": "git",
@@ -48,5 +48,5 @@
48
48
  "sourceMap": false,
49
49
  "instrument": false
50
50
  },
51
- "gitHead": "7388db45c1ac3aee66730d764075ede1429c38db"
51
+ "gitHead": "a013e26d61c852b7c0ed9d76d2ba2516c32a79dc"
52
52
  }
package/src/nativeJs.js CHANGED
@@ -16,12 +16,10 @@ import { Instant, ZoneId } from './js-joda';
16
16
  export function nativeJs(date, zone = ZoneId.systemDefault()) {
17
17
  requireNonNull(date, 'date');
18
18
  requireNonNull(zone, 'zone');
19
- switch (date.constructor.name) {
20
- case 'Date':
21
- return Instant.ofEpochMilli(date.getTime()).atZone(zone);
22
- case 'Moment':
23
- return Instant.ofEpochMilli(date.valueOf()).atZone(zone);
24
- default:
25
- throw new IllegalArgumentException('date must be a javascript Date or a moment instance');
19
+ if(date instanceof Date) {
20
+ return Instant.ofEpochMilli(date.getTime()).atZone(zone);
21
+ } else if(typeof date.toDate === 'function' && date.toDate() instanceof Date) {
22
+ return Instant.ofEpochMilli(date.valueOf()).atZone(zone);
26
23
  }
24
+ throw new IllegalArgumentException('date must be a javascript Date or a moment instance');
27
25
  }