@koine/browser 2.0.0-beta.111 → 2.0.0-beta.113
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/getZonedDate.cjs.js +3 -4
- package/getZonedDate.esm.js +3 -4
- package/index.cjs.js +1 -0
- package/index.esm.js +1 -0
- package/package.json +3 -3
package/getZonedDate.cjs.js
CHANGED
|
@@ -2,11 +2,10 @@
|
|
|
2
2
|
|
|
3
3
|
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
4
|
|
|
5
|
+
var toZonedTime = require('date-fns-tz/toZonedTime');
|
|
5
6
|
var utils = require('@koine/utils');
|
|
6
7
|
|
|
7
|
-
|
|
8
|
-
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
9
|
-
let t=(e,t)=>e;/**
|
|
8
|
+
/**
|
|
10
9
|
* It returns a `Date` object from a date `string` adjusted on the user timeZone,
|
|
11
10
|
* if a timeZone is not provided we try getting it from the `Intl` browwser native
|
|
12
11
|
* API. It gracefully falls back returning a _non-timezone-based_ `Date`.
|
|
@@ -21,7 +20,7 @@ let t=(e,t)=>e;/**
|
|
|
21
20
|
* @param timeZone Optionally pass a timeZone (e.g. from user preference or from the server), it falls back trying to read it from the `Intl` browwser native API.
|
|
22
21
|
*/let getZonedDate=(o="",n)=>{if(o.endsWith("Z")||(o+="Z"),!n&&utils.isBrowser)try{n=Intl.DateTimeFormat().resolvedOptions().timeZone;}catch(e){"development"===process.env.NODE_ENV&&console.warn("[@koine/browser:getZonedDate] failed reading timeZone, error",e);}// no need to do anything here, it just means `Intl` failed, probably
|
|
23
22
|
// because the browser does not support it
|
|
24
|
-
return n?
|
|
23
|
+
return n?toZonedTime.toZonedTime(new Date(o),n):new Date(o)};
|
|
25
24
|
|
|
26
25
|
exports["default"] = getZonedDate;
|
|
27
26
|
exports.getZonedDate = getZonedDate;
|
package/getZonedDate.esm.js
CHANGED
|
@@ -1,8 +1,7 @@
|
|
|
1
|
+
import { toZonedTime } from 'date-fns-tz/toZonedTime';
|
|
1
2
|
import { isBrowser } from '@koine/utils';
|
|
2
3
|
|
|
3
|
-
|
|
4
|
-
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
5
|
-
let t=(e,t)=>e;/**
|
|
4
|
+
/**
|
|
6
5
|
* It returns a `Date` object from a date `string` adjusted on the user timeZone,
|
|
7
6
|
* if a timeZone is not provided we try getting it from the `Intl` browwser native
|
|
8
7
|
* API. It gracefully falls back returning a _non-timezone-based_ `Date`.
|
|
@@ -17,6 +16,6 @@ let t=(e,t)=>e;/**
|
|
|
17
16
|
* @param timeZone Optionally pass a timeZone (e.g. from user preference or from the server), it falls back trying to read it from the `Intl` browwser native API.
|
|
18
17
|
*/let getZonedDate=(o="",n)=>{if(o.endsWith("Z")||(o+="Z"),!n&&isBrowser)try{n=Intl.DateTimeFormat().resolvedOptions().timeZone;}catch(e){"development"===process.env.NODE_ENV&&console.warn("[@koine/browser:getZonedDate] failed reading timeZone, error",e);}// no need to do anything here, it just means `Intl` failed, probably
|
|
19
18
|
// because the browser does not support it
|
|
20
|
-
return n?
|
|
19
|
+
return n?toZonedTime(new Date(o),n):new Date(o)};
|
|
21
20
|
|
|
22
21
|
export { getZonedDate as default, getZonedDate };
|
package/index.cjs.js
CHANGED
package/index.esm.js
CHANGED
package/package.json
CHANGED
|
@@ -2,8 +2,8 @@
|
|
|
2
2
|
"name": "@koine/browser",
|
|
3
3
|
"sideEffects": false,
|
|
4
4
|
"dependencies": {
|
|
5
|
-
"@koine/dom": "2.0.0-beta.
|
|
6
|
-
"@koine/utils": "2.0.0-beta.
|
|
5
|
+
"@koine/dom": "2.0.0-beta.113",
|
|
6
|
+
"@koine/utils": "2.0.0-beta.113"
|
|
7
7
|
},
|
|
8
8
|
"peerDependenciesMeta": {
|
|
9
9
|
"date-fns-tz": {
|
|
@@ -110,5 +110,5 @@
|
|
|
110
110
|
},
|
|
111
111
|
"module": "./index.esm.js",
|
|
112
112
|
"main": "./index.cjs.js",
|
|
113
|
-
"version": "2.0.0-beta.
|
|
113
|
+
"version": "2.0.0-beta.113"
|
|
114
114
|
}
|