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

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 (95) hide show
  1. package/dist/cjs/dates/adapters/ISOToNumericOffset.d.ts +6 -0
  2. package/dist/cjs/dates/adapters/ISOToNumericOffset.js +19 -0
  3. package/dist/cjs/dates/adapters/index.d.ts +2 -0
  4. package/dist/cjs/dates/adapters/index.js +2 -0
  5. package/dist/cjs/dates/adapters/numericOffsetToISO.d.ts +6 -0
  6. package/dist/cjs/dates/adapters/numericOffsetToISO.js +27 -0
  7. package/dist/cjs/dates/constants/ISO_8601_REGEX.d.ts +1 -0
  8. package/dist/cjs/dates/constants/ISO_8601_REGEX.js +4 -0
  9. package/dist/cjs/dates/constants/index.d.ts +1 -0
  10. package/dist/cjs/dates/constants/index.js +1 -0
  11. package/dist/cjs/dates/helpers/getDateByTimezoneOffset.d.ts +7 -0
  12. package/dist/cjs/dates/helpers/getDateByTimezoneOffset.js +25 -0
  13. package/dist/cjs/dates/helpers/index.d.ts +1 -1
  14. package/dist/cjs/dates/helpers/index.js +1 -1
  15. package/dist/cjs/dates/helpers/isValidISOOffset.d.ts +7 -0
  16. package/dist/cjs/dates/helpers/isValidISOOffset.js +17 -0
  17. package/dist/cjs/dates/interfaces/IDTimezoneOffset.d.ts +1 -0
  18. package/dist/cjs/dates/interfaces/IDTimezoneOffset.js +2 -0
  19. package/dist/cjs/dates/interfaces/index.d.ts +1 -0
  20. package/dist/cjs/dates/interfaces/index.js +1 -0
  21. package/dist/cjs/filters/helpers/builder/getFilterBuilderGeneralConfig.js +1 -1
  22. package/dist/cjs/filters/helpers/common/index.d.ts +1 -0
  23. package/dist/cjs/filters/helpers/common/index.js +1 -0
  24. package/dist/cjs/filters/helpers/common/setTimezoneToFilters.d.ts +4 -0
  25. package/dist/cjs/filters/helpers/common/setTimezoneToFilters.js +17 -0
  26. package/dist/cjs/filters/interfaces/ui/IFUTransformFilterValuesSettings.d.ts +2 -0
  27. package/dist/cjs/filters/services/Filters.api.js +1 -1
  28. package/dist/cjs/general/index.d.ts +1 -0
  29. package/dist/cjs/general/index.js +1 -0
  30. package/dist/cjs/general/numeric/getSign.d.ts +6 -0
  31. package/dist/cjs/general/numeric/getSign.js +12 -0
  32. package/dist/cjs/general/numeric/index.d.ts +1 -0
  33. package/dist/cjs/general/numeric/index.js +17 -0
  34. package/dist/cjs/interfaces/general/IWidgetConfig.d.ts +2 -1
  35. package/dist/cjs/qrvey/helpers/transformValue.js +24 -1
  36. package/dist/cjs/qrvey/interfaces/IBDataset.d.ts +2 -0
  37. package/dist/cjs/qrvey/interfaces/IBTimezone.d.ts +4 -0
  38. package/dist/cjs/qrvey/interfaces/IBTimezone.js +2 -0
  39. package/dist/cjs/qrvey/interfaces/IDataset.d.ts +3 -1
  40. package/dist/cjs/qrvey/interfaces/ITransformValueSettings.d.ts +2 -0
  41. package/dist/cjs/qrvey/interfaces/index.d.ts +1 -0
  42. package/dist/cjs/qrvey/interfaces/index.js +1 -0
  43. package/dist/cjs/services/adapters/BDatasetsToUIDatasets.adapter.js +9 -5
  44. package/dist/cjs/services/helpers/Request.d.ts +1 -1
  45. package/dist/cjs/services/helpers/Request.js +6 -5
  46. package/dist/dates/adapters/ISOToNumericOffset.d.ts +6 -0
  47. package/dist/dates/adapters/ISOToNumericOffset.js +15 -0
  48. package/dist/dates/adapters/index.d.ts +2 -0
  49. package/dist/dates/adapters/index.js +2 -0
  50. package/dist/dates/adapters/numericOffsetToISO.d.ts +6 -0
  51. package/dist/dates/adapters/numericOffsetToISO.js +23 -0
  52. package/dist/dates/constants/ISO_8601_REGEX.d.ts +1 -0
  53. package/dist/dates/constants/ISO_8601_REGEX.js +1 -0
  54. package/dist/dates/constants/index.d.ts +1 -0
  55. package/dist/dates/constants/index.js +1 -0
  56. package/dist/dates/helpers/getDateByTimezoneOffset.d.ts +7 -0
  57. package/dist/dates/helpers/getDateByTimezoneOffset.js +21 -0
  58. package/dist/dates/helpers/index.d.ts +1 -1
  59. package/dist/dates/helpers/index.js +1 -1
  60. package/dist/dates/helpers/isValidISOOffset.d.ts +7 -0
  61. package/dist/dates/helpers/isValidISOOffset.js +13 -0
  62. package/dist/dates/interfaces/IDTimezoneOffset.d.ts +1 -0
  63. package/dist/dates/interfaces/IDTimezoneOffset.js +1 -0
  64. package/dist/dates/interfaces/index.d.ts +1 -0
  65. package/dist/dates/interfaces/index.js +1 -0
  66. package/dist/filters/helpers/builder/getFilterBuilderGeneralConfig.js +1 -1
  67. package/dist/filters/helpers/common/index.d.ts +1 -0
  68. package/dist/filters/helpers/common/index.js +1 -0
  69. package/dist/filters/helpers/common/setTimezoneToFilters.d.ts +4 -0
  70. package/dist/filters/helpers/common/setTimezoneToFilters.js +13 -0
  71. package/dist/filters/interfaces/ui/IFUTransformFilterValuesSettings.d.ts +2 -0
  72. package/dist/filters/services/Filters.api.js +1 -1
  73. package/dist/general/index.d.ts +1 -0
  74. package/dist/general/index.js +1 -0
  75. package/dist/general/numeric/getSign.d.ts +6 -0
  76. package/dist/general/numeric/getSign.js +8 -0
  77. package/dist/general/numeric/index.d.ts +1 -0
  78. package/dist/general/numeric/index.js +1 -0
  79. package/dist/interfaces/general/IWidgetConfig.d.ts +2 -1
  80. package/dist/qrvey/helpers/transformValue.js +24 -1
  81. package/dist/qrvey/interfaces/IBDataset.d.ts +2 -0
  82. package/dist/qrvey/interfaces/IBTimezone.d.ts +4 -0
  83. package/dist/qrvey/interfaces/IBTimezone.js +1 -0
  84. package/dist/qrvey/interfaces/IDataset.d.ts +3 -1
  85. package/dist/qrvey/interfaces/ITransformValueSettings.d.ts +2 -0
  86. package/dist/qrvey/interfaces/index.d.ts +1 -0
  87. package/dist/qrvey/interfaces/index.js +1 -0
  88. package/dist/services/adapters/BDatasetsToUIDatasets.adapter.js +9 -5
  89. package/dist/services/helpers/Request.d.ts +1 -1
  90. package/dist/services/helpers/Request.js +6 -5
  91. package/package.json +5 -5
  92. package/dist/cjs/dates/helpers/adjustTimezone.d.ts +0 -6
  93. package/dist/cjs/dates/helpers/adjustTimezone.js +0 -19
  94. package/dist/dates/helpers/adjustTimezone.d.ts +0 -6
  95. package/dist/dates/helpers/adjustTimezone.js +0 -15
@@ -0,0 +1,23 @@
1
+ import { isNaNV2 } from "../../general/mix/isNaNV2";
2
+ import { getSign } from "../../general/numeric/getSign";
3
+ import { padLeadingZeros } from "../../general/string/padLeadingZeros";
4
+ import { isValidISOOffset } from "../helpers/isValidISOOffset";
5
+ /**
6
+ * Gets the ISO offset From the numeric offset (minutes)
7
+ * @param {number} offset the timezone offset
8
+ * @returns {string} the offset in minutes
9
+ */
10
+ export function numericOffsetToISO(offset) {
11
+ let newOffset = offset;
12
+ if (typeof offset === "string" && isValidISOOffset(offset))
13
+ return String(newOffset);
14
+ if (typeof offset !== "number" && isNaNV2(offset))
15
+ return "+00:00";
16
+ if (typeof offset === "string" && !isNaNV2(offset))
17
+ newOffset = +offset;
18
+ const sign = getSign(newOffset);
19
+ newOffset = Math.abs(newOffset);
20
+ const hours = padLeadingZeros(Math.floor(newOffset / 60), 2);
21
+ const minutes = padLeadingZeros(newOffset % 60, 2);
22
+ return `${sign}${hours}:${minutes}`;
23
+ }
@@ -0,0 +1 @@
1
+ export declare const ISO_8601_REGEX: RegExp;
@@ -0,0 +1 @@
1
+ export const ISO_8601_REGEX = /^[+-]?\d{2}:\d{2}$/;
@@ -38,6 +38,7 @@ export * from "./DATE_YEAR_MONTHS_MMMM";
38
38
  export * from "./DATE_YEAR_QUARTERS";
39
39
  export * from "./DATE_YEAR_QUARTERS_RANGE";
40
40
  export * from "./DATETIME_COLUMN_FORMAT";
41
+ export * from "./ISO_8601_REGEX";
41
42
  export * from "./TIME_GROUPING_PROPERTY_INFO_LIST";
42
43
  export * from "./TIME_GROUPING_PROPERTY_INFO";
43
44
  export * from "./TIME_GROUPING_PROPERTY_LABEL";
@@ -38,6 +38,7 @@ export * from "./DATE_YEAR_MONTHS_MMMM";
38
38
  export * from "./DATE_YEAR_QUARTERS";
39
39
  export * from "./DATE_YEAR_QUARTERS_RANGE";
40
40
  export * from "./DATETIME_COLUMN_FORMAT";
41
+ export * from "./ISO_8601_REGEX";
41
42
  export * from "./TIME_GROUPING_PROPERTY_INFO_LIST";
42
43
  export * from "./TIME_GROUPING_PROPERTY_INFO";
43
44
  export * from "./TIME_GROUPING_PROPERTY_LABEL";
@@ -0,0 +1,7 @@
1
+ /**
2
+ * Gets a Date with the given offset of the Timezone.
3
+ * No given an offset the default is going to be set by the browser
4
+ * @param date String, object or millisencond number of the date
5
+ * @returns updated Date object
6
+ */
7
+ export declare function getDateByTimezoneOffset(date: string | Date | number, offset?: number | string): Date;
@@ -0,0 +1,21 @@
1
+ import { isEmpty } from "../../general/mix/isEmpty";
2
+ import { ISOToNumericOffset } from "../adapters/ISOToNumericOffset";
3
+ import { DATE_FORMAT } from "../constants/DATE_FORMAT";
4
+ import { isValidPotentialDate } from "./isValidPotentialDate";
5
+ import { validateDate } from "./validateDate";
6
+ /**
7
+ * Gets a Date with the given offset of the Timezone.
8
+ * No given an offset the default is going to be set by the browser
9
+ * @param date String, object or millisencond number of the date
10
+ * @returns updated Date object
11
+ */
12
+ export function getDateByTimezoneOffset(date, offset) {
13
+ if (!isValidPotentialDate(date) ||
14
+ (typeof date === "string" && !validateDate(date, DATE_FORMAT.DAY)))
15
+ return date;
16
+ const dt = new Date(date.valueOf());
17
+ const newOffset = isEmpty(offset) || offset === "browser"
18
+ ? dt.getTimezoneOffset()
19
+ : ISOToNumericOffset(offset);
20
+ return new Date(+dt + newOffset * 1000 * 60);
21
+ }
@@ -1,4 +1,3 @@
1
- export * from "./adjustTimezone";
2
1
  export * from "./areIncludedDateTokens";
3
2
  export * from "./getDateByDateFormat";
4
3
  export * from "./getDateFormatByProperty";
@@ -10,4 +9,5 @@ export * from "./getSeparatorByDateFormat";
10
9
  export * from "./getWeek";
11
10
  export * from "./isValidDateObject";
12
11
  export * from "./isValidPotentialDate";
12
+ export * from "./getDateByTimezoneOffset";
13
13
  export * from "./validateDate";
@@ -1,4 +1,3 @@
1
- export * from "./adjustTimezone";
2
1
  export * from "./areIncludedDateTokens";
3
2
  export * from "./getDateByDateFormat";
4
3
  export * from "./getDateFormatByProperty";
@@ -10,4 +9,5 @@ export * from "./getSeparatorByDateFormat";
10
9
  export * from "./getWeek";
11
10
  export * from "./isValidDateObject";
12
11
  export * from "./isValidPotentialDate";
12
+ export * from "./getDateByTimezoneOffset";
13
13
  export * from "./validateDate";
@@ -0,0 +1,7 @@
1
+ /**
2
+ * Validate if offset uses a valid ISO 8601 offset specification
3
+ * - If the given offset is a numeric, returns an invalid flag.
4
+ * @param {string} offset the timezone offset
5
+ * @returns {boolean} true if the given offset is valid
6
+ */
7
+ export declare function isValidISOOffset(offset: number | string): boolean;
@@ -0,0 +1,13 @@
1
+ import { ISO_8601_REGEX } from "../constants/ISO_8601_REGEX";
2
+ /**
3
+ * Validate if offset uses a valid ISO 8601 offset specification
4
+ * - If the given offset is a numeric, returns an invalid flag.
5
+ * @param {string} offset the timezone offset
6
+ * @returns {boolean} true if the given offset is valid
7
+ */
8
+ export function isValidISOOffset(offset) {
9
+ if (typeof offset !== "string")
10
+ return false;
11
+ const newOffset = (offset || "").trim();
12
+ return ISO_8601_REGEX.test(newOffset);
13
+ }
@@ -0,0 +1 @@
1
+ export type IDTimezoneOffset = number | string;
@@ -0,0 +1 @@
1
+ export {};
@@ -1,3 +1,4 @@
1
1
  export * from "./IDateFormat";
2
2
  export * from "./IDateGroupingProperty";
3
3
  export * from "./IDFDateToHmsSettings";
4
+ export * from "./IDTimezoneOffset";
@@ -1,3 +1,4 @@
1
1
  export * from "./IDateFormat";
2
2
  export * from "./IDateGroupingProperty";
3
3
  export * from "./IDFDateToHmsSettings";
4
+ export * from "./IDTimezoneOffset";
@@ -11,7 +11,7 @@ export function getFilterBuilderGeneralConfig(config = {}) {
11
11
  domain: config.domain,
12
12
  i18n: config.i18n,
13
13
  qv_token: config.qv_token,
14
- timezoneControl: getAttribute(config, "timezone_control") || config.timezoneControl,
14
+ timezoneOffset: getAttribute(config, "timezone_offset") || config.timezoneOffset,
15
15
  userid: getAttribute(config, "user_id") || config.userid,
16
16
  };
17
17
  }
@@ -28,3 +28,4 @@ export * from "./mergeValues";
28
28
  export * from "./resolveDatasetConditions";
29
29
  export * from "./resolveFilterConditions";
30
30
  export * from "./resolveScopeConditions";
31
+ export * from "./setTimezoneToFilters";
@@ -28,3 +28,4 @@ export * from "./mergeValues";
28
28
  export * from "./resolveDatasetConditions";
29
29
  export * from "./resolveFilterConditions";
30
30
  export * from "./resolveScopeConditions";
31
+ export * from "./setTimezoneToFilters";
@@ -0,0 +1,4 @@
1
+ import { IDTimezoneOffset } from "../../../dates/interfaces/IDTimezoneOffset";
2
+ import { IFSData } from "../../interfaces/common/IFSData";
3
+ import { IFUData } from "../../interfaces/ui/IFUData";
4
+ export declare function setTimezoneToFilters(filterData: IFSData, timezoneOffset: IDTimezoneOffset): IFUData | IFSData;
@@ -0,0 +1,13 @@
1
+ import { isEmpty } from "../../../general/mix/isEmpty";
2
+ import { transformFilterValues } from "../ui/transformFilterValues";
3
+ export function setTimezoneToFilters(filterData, timezoneOffset) {
4
+ if (isEmpty(filterData) ||
5
+ isEmpty(filterData.scopes) ||
6
+ !Array.isArray(filterData.scopes))
7
+ return filterData;
8
+ 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: transformFilterValues(filter, {
9
+ timezoneOffset,
10
+ translate: undefined,
11
+ i18n: undefined,
12
+ }) }))) }))) }))) });
13
+ }
@@ -1,6 +1,8 @@
1
+ import { IDTimezoneOffset } from "../../../dates/interfaces/IDTimezoneOffset";
1
2
  import { II18nConfig } from "../../../globalization/interfaces/II18nConfig";
2
3
  import { II18nServiceTranslate } from "../../../globalization/interfaces/II18nServiceTranslate";
3
4
  export interface IFUTransformFilterValuesSettings {
5
+ timezoneOffset: IDTimezoneOffset;
4
6
  translate: II18nServiceTranslate;
5
7
  i18n: II18nConfig;
6
8
  suffixTranslateLabel?: string;
@@ -97,7 +97,7 @@ export class FiltersApi {
97
97
  else {
98
98
  api = this.chartPaginationApi;
99
99
  }
100
- return api.getChartResult(this.config, FiltersApi.getFilter(config), FiltersApi.getLogic(config), FiltersApi.getChartRequest(config), resetApi);
100
+ return api.getChartResult(Object.assign(Object.assign({}, this.config), { timezoneOffset: 0 }), FiltersApi.getFilter(config), FiltersApi.getLogic(config), FiltersApi.getChartRequest(config), resetApi);
101
101
  });
102
102
  }
103
103
  static getLogic(config) {
@@ -1,5 +1,6 @@
1
1
  export * from "./array/index";
2
2
  export * from "./function/index";
3
3
  export * from "./mix/index";
4
+ export * from "./numeric/index";
4
5
  export * from "./object/index";
5
6
  export * from "./string/index";
@@ -1,5 +1,6 @@
1
1
  export * from "./array/index";
2
2
  export * from "./function/index";
3
3
  export * from "./mix/index";
4
+ export * from "./numeric/index";
4
5
  export * from "./object/index";
5
6
  export * from "./string/index";
@@ -0,0 +1,6 @@
1
+ /**
2
+ * Gets the numeric sign of a given number
3
+ * @param {number} num the number
4
+ * @returns {string} an string with the sign
5
+ */
6
+ export declare function getSign(num: number): string;
@@ -0,0 +1,8 @@
1
+ /**
2
+ * Gets the numeric sign of a given number
3
+ * @param {number} num the number
4
+ * @returns {string} an string with the sign
5
+ */
6
+ export function getSign(num) {
7
+ return Math.sign(num) > -1 ? "+" : "-";
8
+ }
@@ -0,0 +1 @@
1
+ export * from "./getSign";
@@ -0,0 +1 @@
1
+ export * from "./getSign";
@@ -1,3 +1,4 @@
1
+ import { IDTimezoneOffset } from "../../dates/interfaces/IDTimezoneOffset";
1
2
  import { II18nConfig } from "../../globalization/interfaces/II18nConfig";
2
3
  export interface IWidgetConfig {
3
4
  appid?: string;
@@ -5,6 +6,6 @@ export interface IWidgetConfig {
5
6
  domain: string;
6
7
  i18n?: II18nConfig;
7
8
  qv_token?: string;
8
- timezoneControl?: string;
9
+ timezoneOffset?: IDTimezoneOffset;
9
10
  userid?: string;
10
11
  }
@@ -3,6 +3,10 @@ import { isDateColumn } from "../../columns/helpers/isDateColumn";
3
3
  import { isNumericalColumn } from "../../columns/helpers/isNumericalColumn";
4
4
  import { DATE_GROUPING_PROPERTY } from "../../dates/constants/DATE_GROUPING_PROPERTY";
5
5
  import { DATE_GROUPING_TIME_PROPERTY } from "../../dates/constants/DATE_GROUPING_TIME_PROPERTY";
6
+ import { getDateByDateFormat } from "../../dates/helpers/getDateByDateFormat";
7
+ import { getDateFormatByProperty } from "../../dates/helpers/getDateFormatByProperty";
8
+ import { getFormattedDateByFormat } from "../../dates/helpers/getFormattedDateByFormat";
9
+ import { getDateByTimezoneOffset } from "../../dates/helpers/getDateByTimezoneOffset";
6
10
  import { addFormat } from "../../format/format";
7
11
  import { isEmpty } from "../../general/mix/isEmpty";
8
12
  import { getI18nDateGroupLabel } from "../../globalization/helpers/getI18nDateGroupLabel";
@@ -16,13 +20,32 @@ import { getValueWithSuffixes } from "./getValueWithSuffixes";
16
20
  export function transformValue(value, settings) {
17
21
  if (isEmpty(value))
18
22
  return value;
19
- const valueWithI18n = getI18nDateGroupLabel(value, settings.property, settings.translate);
23
+ const timezonedValue = getTimezoneValue(value, settings);
24
+ const valueWithI18n = getI18nDateGroupLabel(timezonedValue, settings.property, settings.translate);
20
25
  const valueWithLocalization = addFormat(valueWithI18n, getOutputFormat(settings), getFormatConfig(settings));
21
26
  return getValueWithSuffixes(valueWithLocalization, {
22
27
  suffixTranslateLabel: settings.suffixTranslateLabel,
23
28
  translate: settings.translate,
24
29
  });
25
30
  }
31
+ /**
32
+ * Gets a date value in the given timezone
33
+ * @param {string} value the date
34
+ * @param {ITransformValueSettings} settings The settings of the transformValue function
35
+ * @returns {string} A transformed value
36
+ */
37
+ function getTimezoneValue(value, settings) {
38
+ const isDateTime = [
39
+ DATE_GROUPING_TIME_PROPERTY.HOUR,
40
+ DATE_GROUPING_TIME_PROPERTY.MINUTE,
41
+ DATE_GROUPING_TIME_PROPERTY.SECOND,
42
+ ].includes(settings.property);
43
+ if (isDateTime) {
44
+ const dateFormat = getDateFormatByProperty(settings.property);
45
+ return getFormattedDateByFormat(getDateByTimezoneOffset(getDateByDateFormat(value, dateFormat), settings === null || settings === void 0 ? void 0 : settings.timezoneOffset), dateFormat);
46
+ }
47
+ return value;
48
+ }
26
49
  /**
27
50
  * Gets the outputformat settings
28
51
  * @param settings The settings of the transformValue function
@@ -1,4 +1,5 @@
1
1
  import { IBColumn } from "../../columns/interfaces/IBColumn";
2
+ import { IBTimezone } from "./IBTimezone";
2
3
  /**
3
4
  * Structure for Dataset in the frontend side of Qrvey App
4
5
  */
@@ -7,4 +8,5 @@ export interface IBDataset {
7
8
  name?: string;
8
9
  options?: IBColumn[];
9
10
  qrveyid: string;
11
+ timezone?: IBTimezone;
10
12
  }
@@ -0,0 +1,4 @@
1
+ export interface IBTimezone {
2
+ numericOffset: number;
3
+ offset: string;
4
+ }
@@ -0,0 +1 @@
1
+ export {};
@@ -1,9 +1,11 @@
1
1
  import { IColumn } from "../../columns/interfaces/IColumn";
2
+ import { IDTimezoneOffset } from "../../dates/interfaces/IDTimezoneOffset";
2
3
  import { IBDataset } from "./IBDataset";
3
4
  /**
4
5
  * Structure for Dataset in the frontend side of Qrvey App
5
6
  */
6
- export interface IDataset extends Omit<IBDataset, "name" | "options"> {
7
+ export interface IDataset extends Omit<IBDataset, "name" | "options" | "timezone"> {
7
8
  label?: string;
8
9
  options?: IColumn[];
10
+ timezone?: IDTimezoneOffset;
9
11
  }
@@ -1,10 +1,12 @@
1
1
  import { IColumn } from "../../columns/interfaces/IColumn";
2
2
  import { IColumnPropertyType } from "../../columns/interfaces/IColumnPropertyType";
3
+ import { IDTimezoneOffset } from "../../dates/interfaces/IDTimezoneOffset";
3
4
  import { II18nConfig } from "../../globalization/interfaces/II18nConfig";
4
5
  import { II18nServiceTranslate } from "../../globalization/interfaces/II18nServiceTranslate";
5
6
  export interface ITransformValueSettings {
6
7
  column: IColumn;
7
8
  property: IColumnPropertyType;
9
+ timezoneOffset: IDTimezoneOffset;
8
10
  translate: II18nServiceTranslate;
9
11
  i18n: II18nConfig;
10
12
  suffixTranslateLabel?: string;
@@ -4,6 +4,7 @@ export * from "./IBDataset";
4
4
  export * from "./IBModel";
5
5
  export * from "./IBModelBranchesMapBranch";
6
6
  export * from "./IBModelData";
7
+ export * from "./IBTimezone";
7
8
  export * from "./ICalculation";
8
9
  export * from "./ICalculationInfo";
9
10
  export * from "./ICalculationType";
@@ -4,6 +4,7 @@ export * from "./IBDataset";
4
4
  export * from "./IBModel";
5
5
  export * from "./IBModelBranchesMapBranch";
6
6
  export * from "./IBModelData";
7
+ export * from "./IBTimezone";
7
8
  export * from "./ICalculation";
8
9
  export * from "./ICalculationInfo";
9
10
  export * from "./ICalculationType";
@@ -1,9 +1,13 @@
1
1
  import { getAttribute } from "../../general/object/getAttribute";
2
2
  import { BColumnsToUIColumns } from "./BColumnsToUIColumns.adapter";
3
3
  export function BDatasetsToUIDatasets(datasets = []) {
4
- return datasets.map((dataset) => ({
5
- qrveyid: getAttribute(dataset, "qrvey_id"),
6
- label: dataset.name,
7
- options: BColumnsToUIColumns(dataset.options, dataset),
8
- }));
4
+ return datasets.map((dataset) => {
5
+ var _a, _b;
6
+ return ({
7
+ qrveyid: getAttribute(dataset, "qrvey_id"),
8
+ label: dataset.name,
9
+ options: BColumnsToUIColumns(dataset.options, dataset),
10
+ timezone: ((_a = dataset.timezone) === null || _a === void 0 ? void 0 : _a.offset) || ((_b = dataset.timezone) === null || _b === void 0 ? void 0 : _b.numericOffset),
11
+ });
12
+ });
9
13
  }
@@ -2,7 +2,7 @@ export default class Request {
2
2
  static checkStatus(response: any): Promise<any>;
3
3
  static hasQvToken(config: any): boolean;
4
4
  static getQvToken(config: any): any;
5
- static getTimezoneControl(config: any): any;
5
+ static getTimezoneOffset(config: any): string;
6
6
  static hasApiKey(config: any): boolean;
7
7
  static getApiKey(config: any): any;
8
8
  static makeUrl(config: any, url: any, params?: any): string;
@@ -7,6 +7,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
7
7
  step((generator = generator.apply(thisArg, _arguments || [])).next());
8
8
  });
9
9
  };
10
+ import { numericOffsetToISO } from "../../dates/adapters/numericOffsetToISO";
10
11
  import { getAttribute } from "../../general/object/getAttribute";
11
12
  import { serialize } from "../../general/object/serialize";
12
13
  import { parseUrl } from "../../general/string/parseUrl";
@@ -24,8 +25,8 @@ export default class Request {
24
25
  static getQvToken(config) {
25
26
  return getAttribute(config, "qv_token");
26
27
  }
27
- static getTimezoneControl(config) {
28
- return getAttribute(config, "timezone_control");
28
+ static getTimezoneOffset(config) {
29
+ return numericOffsetToISO(getAttribute(config, "timezone_offset"));
29
30
  }
30
31
  static hasApiKey(config) {
31
32
  return !!this.getApiKey(config);
@@ -68,9 +69,9 @@ export default class Request {
68
69
  cfg.credentials = "include";
69
70
  }
70
71
  }
71
- const timezoneControl = this.getTimezoneControl(reqData.config);
72
- if (timezoneControl) {
73
- cfg.headers["q-timezone-control"] = `offset=${timezoneControl};use-client-offset-only`;
72
+ const timezoneOffset = this.getTimezoneOffset(reqData.config);
73
+ if (timezoneOffset) {
74
+ cfg.headers["q-timezone-control"] = `offset=${timezoneOffset}`;
74
75
  }
75
76
  // AbortSignal (https://developers.google.com/web/updates/2017/09/abortable-fetch)
76
77
  if (reqData.config && reqData.config.signal) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@qrvey/utils",
3
- "version": "1.10.0-0",
3
+ "version": "1.10.0-timezone-0",
4
4
  "description": "Helper, Utils for all Qrvey Projects",
5
5
  "homepage": "https://bitbucket.org/qrvey/qrvey_utils/wiki/Home",
6
6
  "main": "dist/index.js",
@@ -24,10 +24,10 @@
24
24
  "devDependencies": {
25
25
  "@types/jest": "29.4.0",
26
26
  "@types/responselike": "1.0.0",
27
- "@typescript-eslint/eslint-plugin": "5.49.0",
28
- "@typescript-eslint/parser": "5.49.0",
27
+ "@typescript-eslint/eslint-plugin": "5.50.0",
28
+ "@typescript-eslint/parser": "5.50.0",
29
29
  "auto-changelog": "2.4.0",
30
- "eslint": "8.32.0",
30
+ "eslint": "8.33.0",
31
31
  "eslint-config-prettier": "8.6.0",
32
32
  "eslint-plugin-prettier": "4.2.1",
33
33
  "husky": "8.0.3",
@@ -36,7 +36,7 @@
36
36
  "np": "7.6.3",
37
37
  "prettier": "2.8.3",
38
38
  "ts-jest": "29.0.5",
39
- "typescript": "4.9.4"
39
+ "typescript": "4.9.5"
40
40
  },
41
41
  "dependencies": {
42
42
  "d3-format": "2.0.0",
@@ -1,6 +0,0 @@
1
- /**
2
- * Adjusts a Date with the UTC-0 Timezone.
3
- * @param date String, object or millisencond number of the date
4
- * @returns updated Date object
5
- */
6
- export declare function adjustTimezone(date: string | Date | number): Date;
@@ -1,19 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.adjustTimezone = void 0;
4
- const constants_1 = require("../constants");
5
- const isValidPotentialDate_1 = require("./isValidPotentialDate");
6
- const validateDate_1 = require("./validateDate");
7
- /**
8
- * Adjusts a Date with the UTC-0 Timezone.
9
- * @param date String, object or millisencond number of the date
10
- * @returns updated Date object
11
- */
12
- function adjustTimezone(date) {
13
- if (!(0, isValidPotentialDate_1.isValidPotentialDate)(date) ||
14
- (typeof date === "string" && !(0, validateDate_1.validateDate)(date, constants_1.DATE_FORMAT.DAY)))
15
- return date;
16
- const dt = new Date(date.valueOf());
17
- return new Date(+dt + dt.getTimezoneOffset() * 1000 * 60);
18
- }
19
- exports.adjustTimezone = adjustTimezone;
@@ -1,6 +0,0 @@
1
- /**
2
- * Adjusts a Date with the UTC-0 Timezone.
3
- * @param date String, object or millisencond number of the date
4
- * @returns updated Date object
5
- */
6
- export declare function adjustTimezone(date: string | Date | number): Date;
@@ -1,15 +0,0 @@
1
- import { DATE_FORMAT } from "../constants";
2
- import { isValidPotentialDate } from "./isValidPotentialDate";
3
- import { validateDate } from "./validateDate";
4
- /**
5
- * Adjusts a Date with the UTC-0 Timezone.
6
- * @param date String, object or millisencond number of the date
7
- * @returns updated Date object
8
- */
9
- export function adjustTimezone(date) {
10
- if (!isValidPotentialDate(date) ||
11
- (typeof date === "string" && !validateDate(date, DATE_FORMAT.DAY)))
12
- return date;
13
- const dt = new Date(date.valueOf());
14
- return new Date(+dt + dt.getTimezoneOffset() * 1000 * 60);
15
- }