@dexteel/mesf-core 4.11.0 → 4.11.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/CHANGELOG.md CHANGED
@@ -2,6 +2,13 @@
2
2
 
3
3
  All notable changes to this project will be documented in this file. See [standard-version](https://github.com/conventional-changelog/standard-version) for commit guidelines.
4
4
 
5
+ ### [4.11.1](https://github.com/dexteel/mesf-core-frontend/compare/v4.11.0...v4.11.1) (2024-05-05)
6
+
7
+
8
+ ### Bug Fixes
9
+
10
+ * **TimeService:** Add some try catches and handle utc datetime strings ([b073cd1](https://github.com/dexteel/mesf-core-frontend/commit/b073cd1e1fc3dcceed7a2155ab1a33e21e962805))
11
+
5
12
  ## [4.11.0](https://github.com/dexteel/mesf-core-frontend/compare/v4.10.5...v4.11.0) (2024-05-02)
6
13
 
7
14
 
package/dist/index.esm.js CHANGED
@@ -77,7 +77,8 @@ import 'ag-grid-community/styles/ag-theme-alpine.css';
77
77
  import ImageIcon from '@material-ui/icons/Image';
78
78
  import ListAltIcon from '@material-ui/icons/ListAlt';
79
79
  import DescriptionIcon from '@material-ui/icons/Description';
80
- import { formatInTimeZone } from 'date-fns-tz';
80
+ import { format, fromZonedTime, formatInTimeZone } from 'date-fns-tz';
81
+ import { findIana } from 'windows-iana';
81
82
  import FormControlLabel$1 from '@material-ui/core/FormControlLabel';
82
83
  import Checkbox$1 from '@material-ui/core/Checkbox';
83
84
  import Input from '@material-ui/core/Input';
@@ -7309,16 +7310,45 @@ var TimeService = /** @class */ (function () {
7309
7310
  return TimeService.instance;
7310
7311
  };
7311
7312
  TimeService.prototype.setTimeZone = function (timeZone) {
7312
- this.timeZone = timeZone;
7313
+ var ianaTimeZones = findIana(timeZone);
7314
+ if (ianaTimeZones.length) {
7315
+ this.timeZone = ianaTimeZones[0];
7316
+ }
7317
+ else {
7318
+ this.timeZone = timeZone;
7319
+ }
7313
7320
  };
7314
- TimeService.prototype.toUTC = function (datetime) {
7315
- if (datetime instanceof Date) {
7316
- return datetime.toUTCString();
7321
+ TimeService.prototype.toUTC = function (datetime, format$1) {
7322
+ try {
7323
+ if (datetime instanceof Date) {
7324
+ return format(datetime, format$1);
7325
+ }
7326
+ return format(fromZonedTime(datetime, TimeService.instance.timeZone), format$1);
7327
+ }
7328
+ catch (e) {
7329
+ console.log({ datetime: datetime, e: e });
7330
+ return '';
7317
7331
  }
7318
- return new Date(datetime).toUTCString();
7319
7332
  };
7320
7333
  TimeService.prototype.toLocalServerTime = function (datetime, format) {
7321
- return formatInTimeZone(datetime, TimeService.instance.timeZone, format);
7334
+ try {
7335
+ if (isNil$1(datetime) || !datetime) {
7336
+ return '';
7337
+ }
7338
+ if (typeof datetime === 'string') {
7339
+ if (datetime.includes('Z')) {
7340
+ datetime = new Date(datetime);
7341
+ }
7342
+ else {
7343
+ datetime = new Date("".concat(datetime, "Z"));
7344
+ }
7345
+ }
7346
+ return formatInTimeZone(datetime, TimeService.instance.timeZone, format);
7347
+ }
7348
+ catch (e) {
7349
+ console.log({ datetime: datetime, e: e });
7350
+ return '';
7351
+ }
7322
7352
  };
7323
7353
  return TimeService;
7324
7354
  }());