@adobe/alloy 2.11.0-alpha.2 → 2.11.0-alpha.3

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.
@@ -19,9 +19,14 @@ var _default = function _default(dateProvider) {
19
19
  return function (xdm) {
20
20
  var date = dateProvider();
21
21
  var placeContext = {
22
- localTime: (0, _utils.toISOStringLocal)(date),
23
- localTimezoneOffset: date.getTimezoneOffset()
22
+ localTime: (0, _utils.toISOStringLocal)(date)
24
23
  };
24
+ var localTimezoneOffset = (0, _utils.toInteger)(date.getTimezoneOffset());
25
+
26
+ if (localTimezoneOffset !== undefined) {
27
+ placeContext.localTimezoneOffset = localTimezoneOffset;
28
+ }
29
+
25
30
  (0, _utils.deepAssign)(xdm, {
26
31
  placeContext: placeContext
27
32
  });
@@ -15,5 +15,5 @@ governing permissions and limitations under the License.
15
15
  */
16
16
  // The __VERSION__ keyword will be replace at alloy build time with the package.json version.
17
17
  // see babel-plugin-version
18
- var _default = "2.11.0-alpha.2";
18
+ var _default = "2.11.0-alpha.3";
19
19
  exports.default = _default;
@@ -282,6 +282,12 @@ Object.defineProperty(exports, "toISOStringLocal", {
282
282
  return _toISOStringLocal.default;
283
283
  }
284
284
  });
285
+ Object.defineProperty(exports, "toInteger", {
286
+ enumerable: true,
287
+ get: function get() {
288
+ return _toInteger.default;
289
+ }
290
+ });
285
291
  Object.defineProperty(exports, "updateErrorMessage", {
286
292
  enumerable: true,
287
293
  get: function get() {
@@ -399,6 +405,8 @@ var _toArray = require("./toArray");
399
405
 
400
406
  var _toError = require("./toError");
401
407
 
408
+ var _toInteger = require("./toInteger");
409
+
402
410
  var _toISOStringLocal = require("./toISOStringLocal");
403
411
 
404
412
  var _uuid = require("./uuid");
@@ -4,6 +4,8 @@ exports.default = void 0;
4
4
 
5
5
  var _padStart = require("./padStart");
6
6
 
7
+ var _toInteger = require("./toInteger");
8
+
7
9
  /*
8
10
  Copyright 2019 Adobe. All rights reserved.
9
11
  This file is licensed to you under the Apache License, Version 2.0 (the "License");
@@ -32,7 +34,7 @@ var _default = function _default(date) {
32
34
  // means that the offset is positive if the local timezone is behind UTC and negative if it is
33
35
  // ahead. For example, for time zone UTC+10:00, -600 will be returned.
34
36
 
35
- var timezoneOffset = date.getTimezoneOffset();
37
+ var timezoneOffset = (0, _toInteger.default)(date.getTimezoneOffset(), 0);
36
38
  var ts = timezoneOffset > 0 ? "-" : "+";
37
39
  var th = (0, _padStart.default)(Math.floor(Math.abs(timezoneOffset) / 60), 2, "0");
38
40
  var tm = (0, _padStart.default)(Math.abs(timezoneOffset) % 60, 2, "0");
@@ -0,0 +1,26 @@
1
+ "use strict";
2
+
3
+ exports.default = void 0;
4
+
5
+ /*
6
+ Copyright 2022 Adobe. All rights reserved.
7
+ This file is licensed to you under the Apache License, Version 2.0 (the "License");
8
+ you may not use this file except in compliance with the License. You may obtain a copy
9
+ of the License at http://www.apache.org/licenses/LICENSE-2.0
10
+
11
+ Unless required by applicable law or agreed to in writing, software distributed under
12
+ the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
13
+ OF ANY KIND, either express or implied. See the License for the specific language
14
+ governing permissions and limitations under the License.
15
+ */
16
+
17
+ /*
18
+ * coerce `value` to a number or return `defaultValue` if it cannot be.
19
+ */
20
+ var _default = function _default(value, defaultValue) {
21
+ var n = Math.round(Number(value)); // eslint-disable-next-line no-restricted-globals
22
+
23
+ return isNaN(n) ? defaultValue : n;
24
+ };
25
+
26
+ exports.default = _default;
@@ -9,14 +9,19 @@ the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTA
9
9
  OF ANY KIND, either express or implied. See the License for the specific language
10
10
  governing permissions and limitations under the License.
11
11
  */
12
- import { deepAssign, toISOStringLocal } from "../../utils";
12
+ import { deepAssign, toISOStringLocal, toInteger } from "../../utils";
13
13
  export default (dateProvider => {
14
14
  return xdm => {
15
15
  const date = dateProvider();
16
16
  const placeContext = {
17
- localTime: toISOStringLocal(date),
18
- localTimezoneOffset: date.getTimezoneOffset()
17
+ localTime: toISOStringLocal(date)
19
18
  };
19
+ const localTimezoneOffset = toInteger(date.getTimezoneOffset());
20
+
21
+ if (localTimezoneOffset !== undefined) {
22
+ placeContext.localTimezoneOffset = localTimezoneOffset;
23
+ }
24
+
20
25
  deepAssign(xdm, {
21
26
  placeContext
22
27
  });
@@ -11,4 +11,4 @@ governing permissions and limitations under the License.
11
11
  */
12
12
  // The __VERSION__ keyword will be replace at alloy build time with the package.json version.
13
13
  // see babel-plugin-version
14
- export default "2.11.0-alpha.2";
14
+ export default "2.11.0-alpha.3";
@@ -56,6 +56,7 @@ export { default as startsWith } from "./startsWith";
56
56
  export { default as stringToBoolean } from "./stringToBoolean";
57
57
  export { default as toArray } from "./toArray";
58
58
  export { default as toError } from "./toError";
59
+ export { default as toInteger } from "./toInteger";
59
60
  export { default as toISOStringLocal } from "./toISOStringLocal";
60
61
  export { default as uuid } from "./uuid";
61
62
  export { default as updateErrorMessage } from "./updateErrorMessage";
@@ -10,6 +10,7 @@ OF ANY KIND, either express or implied. See the License for the specific languag
10
10
  governing permissions and limitations under the License.
11
11
  */
12
12
  import padStart from "./padStart";
13
+ import toInteger from "./toInteger";
13
14
  /**
14
15
  * Formats the date into an ISO date-time string in the local timezone
15
16
  * @param {Date} date
@@ -27,7 +28,7 @@ export default (date => {
27
28
  // means that the offset is positive if the local timezone is behind UTC and negative if it is
28
29
  // ahead. For example, for time zone UTC+10:00, -600 will be returned.
29
30
 
30
- const timezoneOffset = date.getTimezoneOffset();
31
+ const timezoneOffset = toInteger(date.getTimezoneOffset(), 0);
31
32
  const ts = timezoneOffset > 0 ? "-" : "+";
32
33
  const th = padStart(Math.floor(Math.abs(timezoneOffset) / 60), 2, "0");
33
34
  const tm = padStart(Math.abs(timezoneOffset) % 60, 2, "0");
@@ -0,0 +1,20 @@
1
+ /*
2
+ Copyright 2022 Adobe. All rights reserved.
3
+ This file is licensed to you under the Apache License, Version 2.0 (the "License");
4
+ you may not use this file except in compliance with the License. You may obtain a copy
5
+ of the License at http://www.apache.org/licenses/LICENSE-2.0
6
+
7
+ Unless required by applicable law or agreed to in writing, software distributed under
8
+ the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
9
+ OF ANY KIND, either express or implied. See the License for the specific language
10
+ governing permissions and limitations under the License.
11
+ */
12
+
13
+ /*
14
+ * coerce `value` to a number or return `defaultValue` if it cannot be.
15
+ */
16
+ export default ((value, defaultValue) => {
17
+ const n = Math.round(Number(value)); // eslint-disable-next-line no-restricted-globals
18
+
19
+ return isNaN(n) ? defaultValue : n;
20
+ });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@adobe/alloy",
3
- "version": "2.11.0-alpha.2",
3
+ "version": "2.11.0-alpha.3",
4
4
  "description": "Adobe Experience Platform Web SDK",
5
5
  "main": "libEs5/index.js",
6
6
  "module": "libEs6/index.js",
@@ -64,7 +64,7 @@
64
64
  "uuid": "^3.3.2"
65
65
  },
66
66
  "devDependencies": {
67
- "@adobe/alloy": "^2.11.0-alpha.1",
67
+ "@adobe/alloy": "^2.11.0-alpha.2",
68
68
  "@babel/cli": "^7.12.8",
69
69
  "@babel/core": "^7.2.2",
70
70
  "@babel/plugin-proposal-object-rest-spread": "^7.3.2",