@pingux/astro 1.8.0-alpha.4 → 1.8.0-alpha.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.
@@ -97,6 +97,18 @@ var getLocaleTime = function getLocaleTime(_ref2) {
97
97
  timeZone: timeZone
98
98
  }, localeOptions));
99
99
  };
100
+
101
+ var getTimezoneOffset = function getTimezoneOffset(timeZone) {
102
+ var now = new Date();
103
+ var tzString = now.toLocaleString('en-US', {
104
+ timeZone: timeZone
105
+ });
106
+ var localString = now.toLocaleString('en-US');
107
+ var diff = (Date.parse(localString) - Date.parse(tzString)) / 3600000;
108
+ var offset = -(diff + now.getTimezoneOffset() / 60);
109
+ var formattedString = "".concat(offset, ":00");
110
+ return offset > 0 ? "+".concat(formattedString) : formattedString;
111
+ };
100
112
  /**
101
113
  * Component allows users to choose a timezone from the list.
102
114
  * You can checkout the default timezones list [here](https://github.com/yury-dymov/react-bootstrap-timezone-picker/blob/master/src/timezones.json).
@@ -143,7 +155,7 @@ var TimeZonePicker = /*#__PURE__*/(0, _react.forwardRef)(function (props, ref) {
143
155
  return (0, _map["default"])(_context5 = (0, _entries["default"])(extendedTimeZonesList)).call(_context5, function (item) {
144
156
  var _item$;
145
157
 
146
- var gmt = item[0].substring(1, 10);
158
+ var gmt = "GMT".concat(getTimezoneOffset(item[1]));
147
159
  var gmtLabel = item[0].substring(12);
148
160
  var timeZone = (_item$ = item[1]) === null || _item$ === void 0 ? void 0 : _item$.replace(/_/g, ' ');
149
161
  var time = getLocaleTime({
@@ -54,6 +54,18 @@ var getLocaleTime = function getLocaleTime(_ref2) {
54
54
  timeZone: timeZone
55
55
  }, localeOptions));
56
56
  };
57
+
58
+ var getTimezoneOffset = function getTimezoneOffset(timeZone) {
59
+ var now = new Date();
60
+ var tzString = now.toLocaleString('en-US', {
61
+ timeZone: timeZone
62
+ });
63
+ var localString = now.toLocaleString('en-US');
64
+ var diff = (Date.parse(localString) - Date.parse(tzString)) / 3600000;
65
+ var offset = -(diff + now.getTimezoneOffset() / 60);
66
+ var formattedString = "".concat(offset, ":00");
67
+ return offset > 0 ? "+".concat(formattedString) : formattedString;
68
+ };
57
69
  /**
58
70
  * Component allows users to choose a timezone from the list.
59
71
  * You can checkout the default timezones list [here](https://github.com/yury-dymov/react-bootstrap-timezone-picker/blob/master/src/timezones.json).
@@ -100,7 +112,7 @@ var TimeZonePicker = /*#__PURE__*/forwardRef(function (props, ref) {
100
112
  return _mapInstanceProperty(_context5 = _Object$entries(extendedTimeZonesList)).call(_context5, function (item) {
101
113
  var _item$;
102
114
 
103
- var gmt = item[0].substring(1, 10);
115
+ var gmt = "GMT".concat(getTimezoneOffset(item[1]));
104
116
  var gmtLabel = item[0].substring(12);
105
117
  var timeZone = (_item$ = item[1]) === null || _item$ === void 0 ? void 0 : _item$.replace(/_/g, ' ');
106
118
  var time = getLocaleTime({
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pingux/astro",
3
- "version": "1.8.0-alpha.4",
3
+ "version": "1.8.0-alpha.5",
4
4
  "description": "PingUX themeable React component library",
5
5
  "author": "ux-development@pingidentity.com",
6
6
  "license": "Apache-2.0",