@qrvey/utils 1.10.0-timezone-0 → 1.10.0-timezone-2

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.
Files changed (79) hide show
  1. package/dist/charts/adapters/endpointData.js +0 -3
  2. package/dist/cjs/charts/adapters/endpointData.js +0 -3
  3. package/dist/cjs/dates/helpers/getDateByTimezone.d.ts +8 -0
  4. package/dist/cjs/dates/helpers/getDateByTimezone.js +39 -0
  5. package/dist/cjs/dates/helpers/getTimezoneObject.d.ts +4 -0
  6. package/dist/cjs/dates/helpers/getTimezoneObject.js +24 -0
  7. package/dist/cjs/dates/helpers/index.d.ts +2 -0
  8. package/dist/cjs/dates/helpers/index.js +2 -0
  9. package/dist/cjs/dates/interfaces/IDTimezone.d.ts +4 -0
  10. package/dist/cjs/dates/interfaces/IDTimezone.js +2 -0
  11. package/dist/cjs/dates/interfaces/IGetDateByTimezoneSettings.d.ts +6 -0
  12. package/dist/cjs/dates/interfaces/IGetDateByTimezoneSettings.js +2 -0
  13. package/dist/cjs/dates/interfaces/index.d.ts +2 -0
  14. package/dist/cjs/dates/interfaces/index.js +2 -0
  15. package/dist/cjs/filters/helpers/builder/getFilterBuilderGeneralConfig.js +1 -1
  16. package/dist/cjs/filters/helpers/common/getFiltersByTimezone.d.ts +10 -0
  17. package/dist/cjs/filters/helpers/common/{setTimezoneToFilters.js → getFiltersByTimezone.js} +13 -4
  18. package/dist/cjs/filters/helpers/common/index.d.ts +1 -1
  19. package/dist/cjs/filters/helpers/common/index.js +1 -1
  20. package/dist/cjs/filters/interfaces/ui/IFUTransformFilterValuesSettings.d.ts +6 -2
  21. package/dist/cjs/filters/services/Filters.api.js +1 -1
  22. package/dist/cjs/format/format.d.ts +1 -1
  23. package/dist/cjs/format/format.js +10 -4
  24. package/dist/cjs/general/object/applyTimezoneDeep.d.ts +8 -0
  25. package/dist/cjs/general/object/applyTimezoneDeep.js +48 -0
  26. package/dist/cjs/general/object/index.d.ts +1 -0
  27. package/dist/cjs/general/object/index.js +1 -0
  28. package/dist/cjs/interfaces/format/IFormatConfig.Interface.d.ts +1 -0
  29. package/dist/cjs/interfaces/general/IWidgetConfig.d.ts +2 -2
  30. package/dist/cjs/qrvey/helpers/transformValue.js +31 -26
  31. package/dist/cjs/qrvey/interfaces/IBModel.d.ts +2 -0
  32. package/dist/cjs/qrvey/interfaces/IDataset.d.ts +2 -2
  33. package/dist/cjs/qrvey/interfaces/IModel.d.ts +3 -1
  34. package/dist/cjs/qrvey/interfaces/ITransformValueSettings.d.ts +6 -2
  35. package/dist/cjs/services/adapters/BDatasetsToUIDatasets.adapter.js +7 -9
  36. package/dist/cjs/services/adapters/BModelToUIModel.adapter.js +2 -0
  37. package/dist/cjs/services/adapters/BTimezoneToUITimezone.d.ts +3 -0
  38. package/dist/cjs/services/adapters/BTimezoneToUITimezone.js +9 -0
  39. package/dist/cjs/services/helpers/Request.js +6 -1
  40. package/dist/dates/helpers/getDateByTimezone.d.ts +8 -0
  41. package/dist/dates/helpers/getDateByTimezone.js +35 -0
  42. package/dist/dates/helpers/getTimezoneObject.d.ts +4 -0
  43. package/dist/dates/helpers/getTimezoneObject.js +20 -0
  44. package/dist/dates/helpers/index.d.ts +2 -0
  45. package/dist/dates/helpers/index.js +2 -0
  46. package/dist/dates/interfaces/IDTimezone.d.ts +4 -0
  47. package/dist/dates/interfaces/IDTimezone.js +1 -0
  48. package/dist/dates/interfaces/IGetDateByTimezoneSettings.d.ts +6 -0
  49. package/dist/dates/interfaces/IGetDateByTimezoneSettings.js +1 -0
  50. package/dist/dates/interfaces/index.d.ts +2 -0
  51. package/dist/dates/interfaces/index.js +2 -0
  52. package/dist/filters/helpers/builder/getFilterBuilderGeneralConfig.js +1 -1
  53. package/dist/filters/helpers/common/getFiltersByTimezone.d.ts +10 -0
  54. package/dist/filters/helpers/common/{setTimezoneToFilters.js → getFiltersByTimezone.js} +11 -2
  55. package/dist/filters/helpers/common/index.d.ts +1 -1
  56. package/dist/filters/helpers/common/index.js +1 -1
  57. package/dist/filters/interfaces/ui/IFUTransformFilterValuesSettings.d.ts +6 -2
  58. package/dist/filters/services/Filters.api.js +1 -1
  59. package/dist/format/format.d.ts +1 -1
  60. package/dist/format/format.js +10 -4
  61. package/dist/general/object/applyTimezoneDeep.d.ts +8 -0
  62. package/dist/general/object/applyTimezoneDeep.js +44 -0
  63. package/dist/general/object/index.d.ts +1 -0
  64. package/dist/general/object/index.js +1 -0
  65. package/dist/interfaces/format/IFormatConfig.Interface.d.ts +1 -0
  66. package/dist/interfaces/general/IWidgetConfig.d.ts +2 -2
  67. package/dist/qrvey/helpers/transformValue.js +31 -26
  68. package/dist/qrvey/interfaces/IBModel.d.ts +2 -0
  69. package/dist/qrvey/interfaces/IDataset.d.ts +2 -2
  70. package/dist/qrvey/interfaces/IModel.d.ts +3 -1
  71. package/dist/qrvey/interfaces/ITransformValueSettings.d.ts +6 -2
  72. package/dist/services/adapters/BDatasetsToUIDatasets.adapter.js +7 -9
  73. package/dist/services/adapters/BModelToUIModel.adapter.js +2 -0
  74. package/dist/services/adapters/BTimezoneToUITimezone.d.ts +3 -0
  75. package/dist/services/adapters/BTimezoneToUITimezone.js +5 -0
  76. package/dist/services/helpers/Request.js +6 -1
  77. package/package.json +1 -1
  78. package/dist/cjs/filters/helpers/common/setTimezoneToFilters.d.ts +0 -4
  79. package/dist/filters/helpers/common/setTimezoneToFilters.d.ts +0 -4
@@ -401,7 +401,6 @@ export function configMetricData(metricObj //
401
401
  }
402
402
  if (data.dateColumn) {
403
403
  const dateColum = data.dateColumn.id;
404
- const timeZoneOffset = 0;
405
404
  // TIME PERIOD
406
405
  try {
407
406
  const timePeriod = data.timePeriod.label;
@@ -409,7 +408,6 @@ export function configMetricData(metricObj //
409
408
  id: dateColum,
410
409
  type: timePeriod,
411
410
  dataType: data.dateColumn.type,
412
- timeZoneOffset,
413
411
  };
414
412
  if (timePeriod === "CUSTOM_RANGE") {
415
413
  const type = data.timePeriodCustomRange.label;
@@ -442,7 +440,6 @@ export function configMetricData(metricObj //
442
440
  id: dateColum,
443
441
  type: comparison,
444
442
  dataType: data.dateColumn.type,
445
- timeZoneOffset,
446
443
  };
447
444
  if (comparison === "CUSTOM_RANGE") {
448
445
  const type = data.comparisonCustomRange.label;
@@ -405,7 +405,6 @@ function configMetricData(metricObj //
405
405
  }
406
406
  if (data.dateColumn) {
407
407
  const dateColum = data.dateColumn.id;
408
- const timeZoneOffset = 0;
409
408
  // TIME PERIOD
410
409
  try {
411
410
  const timePeriod = data.timePeriod.label;
@@ -413,7 +412,6 @@ function configMetricData(metricObj //
413
412
  id: dateColum,
414
413
  type: timePeriod,
415
414
  dataType: data.dateColumn.type,
416
- timeZoneOffset,
417
415
  };
418
416
  if (timePeriod === "CUSTOM_RANGE") {
419
417
  const type = data.timePeriodCustomRange.label;
@@ -446,7 +444,6 @@ function configMetricData(metricObj //
446
444
  id: dateColum,
447
445
  type: comparison,
448
446
  dataType: data.dateColumn.type,
449
- timeZoneOffset,
450
447
  };
451
448
  if (comparison === "CUSTOM_RANGE") {
452
449
  const type = data.comparisonCustomRange.label;
@@ -0,0 +1,8 @@
1
+ import { IGetDateByTimezoneSettings } from "../interfaces/IGetDateByTimezoneSettings";
2
+ /**
3
+ * Gets a date value in the given timezone
4
+ * @param {string} date the date
5
+ * @param {IGetDateByTimezoneSettings} settings The settings of the getDateByTimezone function
6
+ * @returns {string} A transformed value
7
+ */
8
+ export declare function getDateByTimezone(date: string, settings: IGetDateByTimezoneSettings): string;
@@ -0,0 +1,39 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.getDateByTimezone = void 0;
4
+ const isEmpty_1 = require("../../general/mix/isEmpty");
5
+ const DATE_GROUPING_TIME_PROPERTY_1 = require("../constants/DATE_GROUPING_TIME_PROPERTY");
6
+ const getDateByDateFormat_1 = require("./getDateByDateFormat");
7
+ const getDateByTimezoneOffset_1 = require("./getDateByTimezoneOffset");
8
+ const getDateFormatByProperty_1 = require("./getDateFormatByProperty");
9
+ const getFormattedDateByFormat_1 = require("./getFormattedDateByFormat");
10
+ /**
11
+ * Gets a date value in the given timezone
12
+ * @param {string} date the date
13
+ * @param {IGetDateByTimezoneSettings} settings The settings of the getDateByTimezone function
14
+ * @returns {string} A transformed value
15
+ */
16
+ function getDateByTimezone(date, settings) {
17
+ const defaultSettings = getDefaultSettings(settings);
18
+ const isDateTime = [
19
+ DATE_GROUPING_TIME_PROPERTY_1.DATE_GROUPING_TIME_PROPERTY.HOUR,
20
+ DATE_GROUPING_TIME_PROPERTY_1.DATE_GROUPING_TIME_PROPERTY.MINUTE,
21
+ DATE_GROUPING_TIME_PROPERTY_1.DATE_GROUPING_TIME_PROPERTY.SECOND,
22
+ ].includes(defaultSettings.property);
23
+ if (!(0, isEmpty_1.isEmpty)(defaultSettings.timezone.offset) && isDateTime) {
24
+ const dateFormat = (0, getDateFormatByProperty_1.getDateFormatByProperty)(defaultSettings.property);
25
+ const formattedDate = (0, getDateByDateFormat_1.getDateByDateFormat)(date, dateFormat);
26
+ const timezonedDate = (0, getDateByTimezoneOffset_1.getDateByTimezoneOffset)(formattedDate, defaultSettings.timezone.offset);
27
+ return (0, getFormattedDateByFormat_1.getFormattedDateByFormat)(timezonedDate, dateFormat);
28
+ }
29
+ return date;
30
+ }
31
+ exports.getDateByTimezone = getDateByTimezone;
32
+ function getDefaultSettings(settings) {
33
+ return {
34
+ property: settings.property,
35
+ timezone: (settings === null || settings === void 0 ? void 0 : settings.timezone) || {
36
+ offset: undefined,
37
+ },
38
+ };
39
+ }
@@ -0,0 +1,4 @@
1
+ import { IDataset } from "../../qrvey/interfaces/IDataset";
2
+ import { IModel } from "../../qrvey/interfaces/IModel";
3
+ import { IDTimezone } from "../interfaces/IDTimezone";
4
+ export declare function getTimezoneObject(timezone: IDTimezone, model: IModel | IDataset): IDTimezone;
@@ -0,0 +1,24 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.getTimezoneObject = void 0;
4
+ const isEmpty_1 = require("../../general/mix/isEmpty");
5
+ function getTimezoneObject(timezone, model) {
6
+ var _a;
7
+ let newTimezone = {
8
+ offset: "+00:00",
9
+ };
10
+ if ((0, isEmpty_1.isEmpty)(timezone)) {
11
+ if (!(0, isEmpty_1.isEmpty)(model)) {
12
+ newTimezone = {
13
+ offset: ((_a = model.timezone) === null || _a === void 0 ? void 0 : _a.offset) || newTimezone.offset,
14
+ };
15
+ }
16
+ }
17
+ else {
18
+ newTimezone = {
19
+ offset: (timezone === null || timezone === void 0 ? void 0 : timezone.offset) || newTimezone.offset,
20
+ };
21
+ }
22
+ return newTimezone;
23
+ }
24
+ exports.getTimezoneObject = getTimezoneObject;
@@ -1,11 +1,13 @@
1
1
  export * from "./areIncludedDateTokens";
2
2
  export * from "./getDateByDateFormat";
3
+ export * from "./getDateByTimezone";
3
4
  export * from "./getDateFormatByProperty";
4
5
  export * from "./getDateFormatRegularExpressionInArray";
5
6
  export * from "./getDatePickerPickLevel";
6
7
  export * from "./getDateRange";
7
8
  export * from "./getFormattedDateByFormat";
8
9
  export * from "./getSeparatorByDateFormat";
10
+ export * from "./getTimezoneObject";
9
11
  export * from "./getWeek";
10
12
  export * from "./isValidDateObject";
11
13
  export * from "./isValidPotentialDate";
@@ -16,12 +16,14 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
16
16
  Object.defineProperty(exports, "__esModule", { value: true });
17
17
  __exportStar(require("./areIncludedDateTokens"), exports);
18
18
  __exportStar(require("./getDateByDateFormat"), exports);
19
+ __exportStar(require("./getDateByTimezone"), exports);
19
20
  __exportStar(require("./getDateFormatByProperty"), exports);
20
21
  __exportStar(require("./getDateFormatRegularExpressionInArray"), exports);
21
22
  __exportStar(require("./getDatePickerPickLevel"), exports);
22
23
  __exportStar(require("./getDateRange"), exports);
23
24
  __exportStar(require("./getFormattedDateByFormat"), exports);
24
25
  __exportStar(require("./getSeparatorByDateFormat"), exports);
26
+ __exportStar(require("./getTimezoneObject"), exports);
25
27
  __exportStar(require("./getWeek"), exports);
26
28
  __exportStar(require("./isValidDateObject"), exports);
27
29
  __exportStar(require("./isValidPotentialDate"), exports);
@@ -0,0 +1,4 @@
1
+ import { IDTimezoneOffset } from "./IDTimezoneOffset";
2
+ export interface IDTimezone {
3
+ offset: IDTimezoneOffset;
4
+ }
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -0,0 +1,6 @@
1
+ import { IColumnPropertyType } from "../../columns/interfaces/IColumnPropertyType";
2
+ import { IDTimezone } from "./IDTimezone";
3
+ export interface IGetDateByTimezoneSettings {
4
+ property: IColumnPropertyType;
5
+ timezone: IDTimezone;
6
+ }
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -1,4 +1,6 @@
1
1
  export * from "./IDateFormat";
2
2
  export * from "./IDateGroupingProperty";
3
3
  export * from "./IDFDateToHmsSettings";
4
+ export * from "./IDTimezone";
4
5
  export * from "./IDTimezoneOffset";
6
+ export * from "./IGetDateByTimezoneSettings";
@@ -17,4 +17,6 @@ Object.defineProperty(exports, "__esModule", { value: true });
17
17
  __exportStar(require("./IDateFormat"), exports);
18
18
  __exportStar(require("./IDateGroupingProperty"), exports);
19
19
  __exportStar(require("./IDFDateToHmsSettings"), exports);
20
+ __exportStar(require("./IDTimezone"), exports);
20
21
  __exportStar(require("./IDTimezoneOffset"), exports);
22
+ __exportStar(require("./IGetDateByTimezoneSettings"), exports);
@@ -14,7 +14,7 @@ function getFilterBuilderGeneralConfig(config = {}) {
14
14
  domain: config.domain,
15
15
  i18n: config.i18n,
16
16
  qv_token: config.qv_token,
17
- timezoneOffset: (0, getAttribute_1.getAttribute)(config, "timezone_offset") || config.timezoneOffset,
17
+ timezone: config.timezone,
18
18
  userid: (0, getAttribute_1.getAttribute)(config, "user_id") || config.userid,
19
19
  };
20
20
  }
@@ -0,0 +1,10 @@
1
+ import { IDTimezone } from "../../../dates/interfaces/IDTimezone";
2
+ import { IFSData } from "../../interfaces/common/IFSData";
3
+ import { IFUData } from "../../interfaces/ui/IFUData";
4
+ /**
5
+ * Gets and transforms the Filter Data by the Timezone object
6
+ * @param {IFSData | IFUData} filterData the filter data
7
+ * @param {IDTimezone} timezone the timezone object
8
+ * @returns {IFSData | IFUData} the new filter data with the transformed datetime values
9
+ */
10
+ export declare function getFiltersByTimezone(filterData: IFSData | IFUData, timezone: IDTimezone): IFUData | IFSData;
@@ -1,17 +1,26 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.setTimezoneToFilters = void 0;
3
+ exports.getFiltersByTimezone = void 0;
4
4
  const isEmpty_1 = require("../../../general/mix/isEmpty");
5
5
  const transformFilterValues_1 = require("../ui/transformFilterValues");
6
- function setTimezoneToFilters(filterData, timezoneOffset) {
6
+ /**
7
+ * Gets and transforms the Filter Data by the Timezone object
8
+ * @param {IFSData | IFUData} filterData the filter data
9
+ * @param {IDTimezone} timezone the timezone object
10
+ * @returns {IFSData | IFUData} the new filter data with the transformed datetime values
11
+ */
12
+ function getFiltersByTimezone(filterData, timezone) {
7
13
  if ((0, isEmpty_1.isEmpty)(filterData) ||
8
14
  (0, isEmpty_1.isEmpty)(filterData.scopes) ||
9
15
  !Array.isArray(filterData.scopes))
10
16
  return filterData;
11
17
  return Object.assign(Object.assign({}, filterData), { scopes: filterData.scopes.map((scope) => (Object.assign(Object.assign({}, scope), { datasets: scope.datasets.map((dataset) => (Object.assign(Object.assign({}, dataset), { filters: dataset.filters.map((filter) => (Object.assign(Object.assign({}, filter), { values: (0, transformFilterValues_1.transformFilterValues)(filter, {
12
- timezoneOffset,
18
+ timezone,
13
19
  translate: undefined,
14
20
  i18n: undefined,
21
+ noLocale: true,
22
+ noSuffix: true,
23
+ noTranslate: true,
15
24
  }) }))) }))) }))) });
16
25
  }
17
- exports.setTimezoneToFilters = setTimezoneToFilters;
26
+ exports.getFiltersByTimezone = getFiltersByTimezone;
@@ -10,6 +10,7 @@ export * from "./getFiltersByDatasetsColumns";
10
10
  export * from "./getFiltersByParams";
11
11
  export * from "./getFiltersByScopes";
12
12
  export * from "./getFiltersByScopesIds";
13
+ export * from "./getFiltersByTimezone";
13
14
  export * from "./getFiltersByVisibility";
14
15
  export * from "./getMergeFiltersSettings";
15
16
  export * from "./getParamsToGetFilterSettings";
@@ -28,4 +29,3 @@ export * from "./mergeValues";
28
29
  export * from "./resolveDatasetConditions";
29
30
  export * from "./resolveFilterConditions";
30
31
  export * from "./resolveScopeConditions";
31
- export * from "./setTimezoneToFilters";
@@ -26,6 +26,7 @@ __exportStar(require("./getFiltersByDatasetsColumns"), exports);
26
26
  __exportStar(require("./getFiltersByParams"), exports);
27
27
  __exportStar(require("./getFiltersByScopes"), exports);
28
28
  __exportStar(require("./getFiltersByScopesIds"), exports);
29
+ __exportStar(require("./getFiltersByTimezone"), exports);
29
30
  __exportStar(require("./getFiltersByVisibility"), exports);
30
31
  __exportStar(require("./getMergeFiltersSettings"), exports);
31
32
  __exportStar(require("./getParamsToGetFilterSettings"), exports);
@@ -44,4 +45,3 @@ __exportStar(require("./mergeValues"), exports);
44
45
  __exportStar(require("./resolveDatasetConditions"), exports);
45
46
  __exportStar(require("./resolveFilterConditions"), exports);
46
47
  __exportStar(require("./resolveScopeConditions"), exports);
47
- __exportStar(require("./setTimezoneToFilters"), exports);
@@ -1,9 +1,13 @@
1
- import { IDTimezoneOffset } from "../../../dates/interfaces/IDTimezoneOffset";
1
+ import { IDTimezone } from "../../../dates/interfaces/IDTimezone";
2
2
  import { II18nConfig } from "../../../globalization/interfaces/II18nConfig";
3
3
  import { II18nServiceTranslate } from "../../../globalization/interfaces/II18nServiceTranslate";
4
4
  export interface IFUTransformFilterValuesSettings {
5
- timezoneOffset: IDTimezoneOffset;
5
+ timezone?: IDTimezone;
6
6
  translate: II18nServiceTranslate;
7
7
  i18n: II18nConfig;
8
8
  suffixTranslateLabel?: string;
9
+ noLocale?: boolean;
10
+ noTranslate?: boolean;
11
+ noSuffix?: boolean;
12
+ noTimezone?: boolean;
9
13
  }
@@ -103,7 +103,7 @@ class FiltersApi {
103
103
  else {
104
104
  api = this.chartPaginationApi;
105
105
  }
106
- return api.getChartResult(Object.assign(Object.assign({}, this.config), { timezoneOffset: 0 }), FiltersApi.getFilter(config), FiltersApi.getLogic(config), FiltersApi.getChartRequest(config), resetApi);
106
+ return api.getChartResult(this.config, FiltersApi.getFilter(config), FiltersApi.getLogic(config), FiltersApi.getChartRequest(config), resetApi);
107
107
  });
108
108
  }
109
109
  static getLogic(config) {
@@ -1,5 +1,5 @@
1
1
  import { IFormatConfig } from "../interfaces/format/IFormatConfig.Interface";
2
- export declare function formatDate(dateString: any, format: any): any;
2
+ export declare function formatDate(dateString: any, format: any, offset: any): any;
3
3
  export declare function formatAbbreviated(num: any, decimals: any): any;
4
4
  /**
5
5
  * Set convert Bytes into MB
@@ -9,6 +9,7 @@ const dayjs_1 = __importDefault(require("dayjs"));
9
9
  const definition_1 = require("./definition");
10
10
  const isoWeek_1 = __importDefault(require("dayjs/plugin/isoWeek"));
11
11
  const advancedFormat_1 = __importDefault(require("dayjs/plugin/advancedFormat"));
12
+ const utc_1 = __importDefault(require("dayjs/plugin/utc"));
12
13
  const isEmpty_1 = require("../general/mix/isEmpty");
13
14
  const get_1 = require("../general/object/get");
14
15
  const COLUMN_1 = require("../columns/constants/COLUMN");
@@ -19,6 +20,7 @@ const DURATION_PARTS_LIST_1 = require("../column_format/constants/DURATION_PARTS
19
20
  const cloneDeep_1 = require("../general/object/cloneDeep");
20
21
  dayjs_1.default.extend(isoWeek_1.default); // Add support for iso week format https://github.com/iamkun/dayjs/issues/1328
21
22
  dayjs_1.default.extend(advancedFormat_1.default); // Add support to advanced formats https://day.js.org/docs/en/plugin/advanced-format
23
+ dayjs_1.default.extend(utc_1.default);
22
24
  /**
23
25
  * Apply to the given date format to a date value
24
26
  * @param bytes type number
@@ -27,7 +29,7 @@ function isValidDateString(dateString = "") {
27
29
  return (/^\d{2}\/\d{2}\/\d{4}/.test(dateString) || // MM/DD/YYY OR DD/MM/YYYY
28
30
  /^\d{4}-\d{2}-\d{2}/.test(dateString)); // YYYY-MM-DD
29
31
  }
30
- function formatDate(dateString, format) {
32
+ function formatDate(dateString, format, offset) {
31
33
  let _format = (0, cloneDeep_1.cloneDeep)(format);
32
34
  if ((0, isObject_1.isObject)(format))
33
35
  _format = _format.format || "";
@@ -35,8 +37,12 @@ function formatDate(dateString, format) {
35
37
  return dateString;
36
38
  if (!isValidDateString(dateString))
37
39
  return dateString;
38
- const dateValue = dateString === null || dateString === void 0 ? void 0 : dateString.replace(/Z$/i, "");
39
- return (0, dayjs_1.default)(dateValue.split(".")[0]).format(_format
40
+ const dateStringCleaned = dateString === null || dateString === void 0 ? void 0 : dateString.replace(/Z$/i, "");
41
+ const firstPartOfDateString = (0, dayjs_1.default)(dateStringCleaned.split(".")[0]);
42
+ const newDateValue = !(0, isEmpty_1.isEmpty)(offset)
43
+ ? firstPartOfDateString.utcOffset(offset)
44
+ : firstPartOfDateString;
45
+ return newDateValue.format(_format
40
46
  .replace("HH24:", "HH:")
41
47
  .replace("MI:SS", "mm:ss")
42
48
  .replace("MM:SS", "mm:ss"));
@@ -146,7 +152,7 @@ const addFormat = (value, outputFormat = "None", config) => {
146
152
  : formatDate(value, (outputFormat === null || outputFormat === void 0 ? void 0 : outputFormat.format) === "Default" &&
147
153
  ((_c = outputFormat === null || outputFormat === void 0 ? void 0 : outputFormat.originalFormat) === null || _c === void 0 ? void 0 : _c.format)
148
154
  ? (_d = outputFormat === null || outputFormat === void 0 ? void 0 : outputFormat.originalFormat) === null || _d === void 0 ? void 0 : _d.format
149
- : outputFormat === null || outputFormat === void 0 ? void 0 : outputFormat.format);
155
+ : outputFormat === null || outputFormat === void 0 ? void 0 : outputFormat.format, config === null || config === void 0 ? void 0 : config.offset);
150
156
  case "NUMERIC": {
151
157
  const parse = parseFloat(value);
152
158
  const withLocale = (outputFormat !== "None" && (config === null || config === void 0 ? void 0 : config.lang)) ||
@@ -0,0 +1,8 @@
1
+ import { IDTimezone } from "../../dates/interfaces/IDTimezone";
2
+ /**
3
+ * Transforms the date+times propertiesof the given object by the Timezone object
4
+ * @param {any} obj the object
5
+ * @param {IDTimezone} timezone the timezone object
6
+ * @returns {IFSData | IFUData} the new filter data with the transformed datetime values
7
+ */
8
+ export declare function applyTimezoneDeep(obj: any, timezone: IDTimezone): any;
@@ -0,0 +1,48 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.applyTimezoneDeep = void 0;
4
+ const DATE_FORMAT_1 = require("../../dates/constants/DATE_FORMAT");
5
+ const DATE_GROUPING_TIME_PROPERTY_1 = require("../../dates/constants/DATE_GROUPING_TIME_PROPERTY");
6
+ const getDateByTimezone_1 = require("../../dates/helpers/getDateByTimezone");
7
+ const validateDate_1 = require("../../dates/helpers/validateDate");
8
+ const isEmpty_1 = require("../mix/isEmpty");
9
+ const isObject_1 = require("./isObject");
10
+ /**
11
+ * Transforms the date+times propertiesof the given object by the Timezone object
12
+ * @param {any} obj the object
13
+ * @param {IDTimezone} timezone the timezone object
14
+ * @returns {IFSData | IFUData} the new filter data with the transformed datetime values
15
+ */
16
+ function applyTimezoneDeep(obj, timezone) {
17
+ if ((0, isEmpty_1.isEmpty)(obj))
18
+ return obj;
19
+ let result;
20
+ if ((0, isObject_1.isObject)(obj)) {
21
+ result = {};
22
+ }
23
+ else if (Array.isArray(obj)) {
24
+ result = [];
25
+ }
26
+ try {
27
+ for (const i in obj) {
28
+ if ((0, isObject_1.isObject)(obj[i]) || Array.isArray(obj[i])) {
29
+ result[i] = applyTimezoneDeep(obj[i], timezone);
30
+ }
31
+ else if (obj[i] instanceof Date ||
32
+ (0, validateDate_1.validateDate)(obj[i], DATE_FORMAT_1.DATE_FORMAT.HOUR)) {
33
+ result[i] = (0, getDateByTimezone_1.getDateByTimezone)(obj[i], {
34
+ property: DATE_GROUPING_TIME_PROPERTY_1.DATE_GROUPING_TIME_PROPERTY.HOUR,
35
+ timezone,
36
+ });
37
+ }
38
+ else {
39
+ result[i] = obj[i];
40
+ }
41
+ }
42
+ return result;
43
+ }
44
+ catch (_a) {
45
+ return obj;
46
+ }
47
+ }
48
+ exports.applyTimezoneDeep = applyTimezoneDeep;
@@ -1,3 +1,4 @@
1
+ export * from "./applyTimezoneDeep";
1
2
  export * from "./cloneDeep";
2
3
  export * from "./get";
3
4
  export * from "./getAttribute";
@@ -14,6 +14,7 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
14
  for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
15
  };
16
16
  Object.defineProperty(exports, "__esModule", { value: true });
17
+ __exportStar(require("./applyTimezoneDeep"), exports);
17
18
  __exportStar(require("./cloneDeep"), exports);
18
19
  __exportStar(require("./get"), exports);
19
20
  __exportStar(require("./getAttribute"), exports);
@@ -1,5 +1,6 @@
1
1
  export interface IFormatConfig {
2
2
  lang?: string;
3
+ offset?: number;
3
4
  options?: object;
4
5
  isMultiplied?: boolean;
5
6
  }
@@ -1,4 +1,4 @@
1
- import { IDTimezoneOffset } from "../../dates/interfaces/IDTimezoneOffset";
1
+ import { IDTimezone } from "../../dates/interfaces/IDTimezone";
2
2
  import { II18nConfig } from "../../globalization/interfaces/II18nConfig";
3
3
  export interface IWidgetConfig {
4
4
  appid?: string;
@@ -6,6 +6,6 @@ export interface IWidgetConfig {
6
6
  domain: string;
7
7
  i18n?: II18nConfig;
8
8
  qv_token?: string;
9
- timezoneOffset?: IDTimezoneOffset;
9
+ timezone?: IDTimezone;
10
10
  userid?: string;
11
11
  }
@@ -6,14 +6,11 @@ const isDateColumn_1 = require("../../columns/helpers/isDateColumn");
6
6
  const isNumericalColumn_1 = require("../../columns/helpers/isNumericalColumn");
7
7
  const DATE_GROUPING_PROPERTY_1 = require("../../dates/constants/DATE_GROUPING_PROPERTY");
8
8
  const DATE_GROUPING_TIME_PROPERTY_1 = require("../../dates/constants/DATE_GROUPING_TIME_PROPERTY");
9
- const getDateByDateFormat_1 = require("../../dates/helpers/getDateByDateFormat");
10
- const getDateFormatByProperty_1 = require("../../dates/helpers/getDateFormatByProperty");
11
- const getFormattedDateByFormat_1 = require("../../dates/helpers/getFormattedDateByFormat");
12
- const getDateByTimezoneOffset_1 = require("../../dates/helpers/getDateByTimezoneOffset");
13
9
  const format_1 = require("../../format/format");
14
10
  const isEmpty_1 = require("../../general/mix/isEmpty");
15
11
  const getI18nDateGroupLabel_1 = require("../../globalization/helpers/getI18nDateGroupLabel");
16
12
  const getValueWithSuffixes_1 = require("./getValueWithSuffixes");
13
+ const getDateByTimezone_1 = require("../../dates/helpers/getDateByTimezone");
17
14
  /**
18
15
  * Transforms a value depending of localization/globalization and extras settings.
19
16
  * @param value A value to transform
@@ -23,32 +20,40 @@ const getValueWithSuffixes_1 = require("./getValueWithSuffixes");
23
20
  function transformValue(value, settings) {
24
21
  if ((0, isEmpty_1.isEmpty)(value))
25
22
  return value;
26
- const timezonedValue = getTimezoneValue(value, settings);
27
- const valueWithI18n = (0, getI18nDateGroupLabel_1.getI18nDateGroupLabel)(timezonedValue, settings.property, settings.translate);
28
- const valueWithLocalization = (0, format_1.addFormat)(valueWithI18n, getOutputFormat(settings), getFormatConfig(settings));
29
- return (0, getValueWithSuffixes_1.getValueWithSuffixes)(valueWithLocalization, {
30
- suffixTranslateLabel: settings.suffixTranslateLabel,
31
- translate: settings.translate,
32
- });
23
+ const defaultSettings = getDefaultSettings(settings);
24
+ let timezonedValue = value;
25
+ if (!defaultSettings.noTimezone) {
26
+ timezonedValue = (0, getDateByTimezone_1.getDateByTimezone)(value, {
27
+ property: defaultSettings.property,
28
+ timezone: defaultSettings.timezone,
29
+ });
30
+ }
31
+ let valueWithI18n = timezonedValue;
32
+ if (!defaultSettings.noTranslate) {
33
+ valueWithI18n = (0, getI18nDateGroupLabel_1.getI18nDateGroupLabel)(timezonedValue, defaultSettings.property, defaultSettings.translate);
34
+ }
35
+ let valueWithLocalization = valueWithI18n;
36
+ if (!defaultSettings.noLocale) {
37
+ valueWithLocalization = (0, format_1.addFormat)(valueWithI18n, getOutputFormat(settings), getFormatConfig(settings));
38
+ }
39
+ let valueWithSuffix = valueWithI18n;
40
+ if (!defaultSettings.noSuffix) {
41
+ valueWithSuffix = (0, getValueWithSuffixes_1.getValueWithSuffixes)(valueWithLocalization, {
42
+ suffixTranslateLabel: defaultSettings.suffixTranslateLabel,
43
+ translate: defaultSettings.translate,
44
+ });
45
+ }
46
+ return valueWithSuffix;
33
47
  }
34
48
  exports.transformValue = transformValue;
35
49
  /**
36
- * Gets a date value in the given timezone
37
- * @param {string} value the date
38
- * @param {ITransformValueSettings} settings The settings of the transformValue function
39
- * @returns {string} A transformed value
50
+ * Gets the default settings properties
51
+ * @param {ITransformValueSettings} settings the given settings
52
+ * @returns {ITransformValueSettings} the settings with default properties
40
53
  */
41
- function getTimezoneValue(value, settings) {
42
- const isDateTime = [
43
- DATE_GROUPING_TIME_PROPERTY_1.DATE_GROUPING_TIME_PROPERTY.HOUR,
44
- DATE_GROUPING_TIME_PROPERTY_1.DATE_GROUPING_TIME_PROPERTY.MINUTE,
45
- DATE_GROUPING_TIME_PROPERTY_1.DATE_GROUPING_TIME_PROPERTY.SECOND,
46
- ].includes(settings.property);
47
- if (isDateTime) {
48
- const dateFormat = (0, getDateFormatByProperty_1.getDateFormatByProperty)(settings.property);
49
- return (0, getFormattedDateByFormat_1.getFormattedDateByFormat)((0, getDateByTimezoneOffset_1.getDateByTimezoneOffset)((0, getDateByDateFormat_1.getDateByDateFormat)(value, dateFormat), settings === null || settings === void 0 ? void 0 : settings.timezoneOffset), dateFormat);
50
- }
51
- return value;
54
+ function getDefaultSettings(settings) {
55
+ var _a, _b, _c, _d;
56
+ return Object.assign(Object.assign({}, settings), { noLocale: (_a = settings === null || settings === void 0 ? void 0 : settings.noLocale) !== null && _a !== void 0 ? _a : false, noSuffix: (_b = settings === null || settings === void 0 ? void 0 : settings.noSuffix) !== null && _b !== void 0 ? _b : false, noTimezone: (_c = settings === null || settings === void 0 ? void 0 : settings.noTimezone) !== null && _c !== void 0 ? _c : false, noTranslate: (_d = settings === null || settings === void 0 ? void 0 : settings.noTranslate) !== null && _d !== void 0 ? _d : false });
52
57
  }
53
58
  /**
54
59
  * Gets the outputformat settings
@@ -2,6 +2,7 @@ import { IAppStatus } from "./IAppStatus";
2
2
  import { IBModelBranchesMap } from "./IBModelBranchesMap";
3
3
  import { IBModelData } from "./IBModelData";
4
4
  import { IAppType } from "./IAppType";
5
+ import { IBTimezone } from "./IBTimezone";
5
6
  export interface IBModel {
6
7
  appType: IAppType;
7
8
  appid: string;
@@ -16,5 +17,6 @@ export interface IBModel {
16
17
  questionOrder: string[];
17
18
  questions: IBModelData;
18
19
  status: IAppStatus;
20
+ timezone: IBTimezone;
19
21
  userid: string;
20
22
  }
@@ -1,5 +1,5 @@
1
1
  import { IColumn } from "../../columns/interfaces/IColumn";
2
- import { IDTimezoneOffset } from "../../dates/interfaces/IDTimezoneOffset";
2
+ import { IDTimezone } from "../../dates/interfaces/IDTimezone";
3
3
  import { IBDataset } from "./IBDataset";
4
4
  /**
5
5
  * Structure for Dataset in the frontend side of Qrvey App
@@ -7,5 +7,5 @@ import { IBDataset } from "./IBDataset";
7
7
  export interface IDataset extends Omit<IBDataset, "name" | "options" | "timezone"> {
8
8
  label?: string;
9
9
  options?: IColumn[];
10
- timezone?: IDTimezoneOffset;
10
+ timezone?: IDTimezone;
11
11
  }
@@ -1,10 +1,12 @@
1
1
  import { IColumn } from "../../columns/interfaces/IColumn";
2
+ import { IDTimezone } from "../../dates/interfaces/IDTimezone";
2
3
  import { IBModel } from "./IBModel";
3
4
  import { IModelBranchesMap } from "./IModelBranchesMap";
4
- export interface IModel extends Omit<IBModel, "questions" | "branchesMap" | "name" | "numResponses" | "questionOrder"> {
5
+ export interface IModel extends Omit<IBModel, "questions" | "branchesMap" | "name" | "numResponses" | "questionOrder" | "timezone"> {
5
6
  columns: IColumn[];
6
7
  columnOrder: string[];
7
8
  branchesMap: IModelBranchesMap[];
8
9
  label: string;
10
+ timezone: IDTimezone;
9
11
  totalRecords: number;
10
12
  }
@@ -1,13 +1,17 @@
1
1
  import { IColumn } from "../../columns/interfaces/IColumn";
2
2
  import { IColumnPropertyType } from "../../columns/interfaces/IColumnPropertyType";
3
- import { IDTimezoneOffset } from "../../dates/interfaces/IDTimezoneOffset";
3
+ import { IDTimezone } from "../../dates/interfaces/IDTimezone";
4
4
  import { II18nConfig } from "../../globalization/interfaces/II18nConfig";
5
5
  import { II18nServiceTranslate } from "../../globalization/interfaces/II18nServiceTranslate";
6
6
  export interface ITransformValueSettings {
7
7
  column: IColumn;
8
8
  property: IColumnPropertyType;
9
- timezoneOffset: IDTimezoneOffset;
9
+ timezone?: IDTimezone;
10
10
  translate: II18nServiceTranslate;
11
11
  i18n: II18nConfig;
12
12
  suffixTranslateLabel?: string;
13
+ noLocale?: boolean;
14
+ noTranslate?: boolean;
15
+ noSuffix?: boolean;
16
+ noTimezone?: boolean;
13
17
  }
@@ -3,15 +3,13 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.BDatasetsToUIDatasets = void 0;
4
4
  const getAttribute_1 = require("../../general/object/getAttribute");
5
5
  const BColumnsToUIColumns_adapter_1 = require("./BColumnsToUIColumns.adapter");
6
+ const BTimezoneToUITimezone_1 = require("./BTimezoneToUITimezone");
6
7
  function BDatasetsToUIDatasets(datasets = []) {
7
- return datasets.map((dataset) => {
8
- var _a, _b;
9
- return ({
10
- qrveyid: (0, getAttribute_1.getAttribute)(dataset, "qrvey_id"),
11
- label: dataset.name,
12
- options: (0, BColumnsToUIColumns_adapter_1.BColumnsToUIColumns)(dataset.options, dataset),
13
- timezone: ((_a = dataset.timezone) === null || _a === void 0 ? void 0 : _a.offset) || ((_b = dataset.timezone) === null || _b === void 0 ? void 0 : _b.numericOffset),
14
- });
15
- });
8
+ return datasets.map((dataset) => ({
9
+ qrveyid: (0, getAttribute_1.getAttribute)(dataset, "qrvey_id"),
10
+ label: dataset.name,
11
+ options: (0, BColumnsToUIColumns_adapter_1.BColumnsToUIColumns)(dataset.options, dataset),
12
+ timezone: (0, BTimezoneToUITimezone_1.BTimezoneToUITimezone)(dataset.timezone),
13
+ }));
16
14
  }
17
15
  exports.BDatasetsToUIDatasets = BDatasetsToUIDatasets;