@qrvey/utils 1.10.0-7 → 1.10.0-9

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 (89) hide show
  1. package/dist/cjs/columns/constants/COLUMN_PROPERTIES.d.ts +1 -1
  2. package/dist/cjs/dates/adapters/dateToHms.js +8 -10
  3. package/dist/cjs/dates/adapters/dateToMdyDate.d.ts +2 -1
  4. package/dist/cjs/dates/adapters/dateToMdyDate.js +9 -3
  5. package/dist/cjs/dates/adapters/dateToMonthYear.d.ts +2 -1
  6. package/dist/cjs/dates/adapters/dateToMonthYear.js +7 -3
  7. package/dist/cjs/dates/adapters/dateToQuarterYear.d.ts +2 -1
  8. package/dist/cjs/dates/adapters/dateToQuarterYear.js +8 -4
  9. package/dist/cjs/dates/adapters/dateToWeekYear.d.ts +2 -1
  10. package/dist/cjs/dates/adapters/dateToWeekYear.js +6 -2
  11. package/dist/cjs/dates/adapters/dateToYear.d.ts +2 -1
  12. package/dist/cjs/dates/adapters/dateToYear.js +7 -3
  13. package/dist/cjs/dates/adapters/hmsToDate.d.ts +2 -1
  14. package/dist/cjs/dates/adapters/hmsToDate.js +6 -2
  15. package/dist/cjs/dates/adapters/mdyDateToDate.d.ts +2 -1
  16. package/dist/cjs/dates/adapters/mdyDateToDate.js +7 -2
  17. package/dist/cjs/dates/adapters/monthYearToDate.d.ts +2 -1
  18. package/dist/cjs/dates/adapters/monthYearToDate.js +6 -2
  19. package/dist/cjs/dates/adapters/quarterYearToDate.d.ts +2 -1
  20. package/dist/cjs/dates/adapters/quarterYearToDate.js +6 -2
  21. package/dist/cjs/dates/adapters/weekYearToDate.d.ts +2 -1
  22. package/dist/cjs/dates/adapters/weekYearToDate.js +10 -6
  23. package/dist/cjs/dates/adapters/yearToDate.d.ts +2 -1
  24. package/dist/cjs/dates/adapters/yearToDate.js +6 -2
  25. package/dist/cjs/dates/helpers/getDateByDateFormat.d.ts +2 -1
  26. package/dist/cjs/dates/helpers/getDateByDateFormat.js +6 -6
  27. package/dist/cjs/dates/helpers/getDateByTimezone.d.ts +3 -3
  28. package/dist/cjs/dates/helpers/getDateByTimezone.js +12 -29
  29. package/dist/cjs/dates/helpers/getDateByTimezoneOffset.d.ts +1 -1
  30. package/dist/cjs/dates/helpers/getDateByTimezoneOffset.js +13 -2
  31. package/dist/cjs/dates/helpers/getDefaultDateSettings.d.ts +7 -0
  32. package/dist/cjs/dates/helpers/getDefaultDateSettings.js +17 -0
  33. package/dist/cjs/dates/helpers/getFormattedDateByFormat.d.ts +2 -1
  34. package/dist/cjs/dates/helpers/getFormattedDateByFormat.js +7 -7
  35. package/dist/cjs/dates/helpers/getWeek.js +6 -6
  36. package/dist/cjs/dates/interfaces/IDFDateToHmsSettings.d.ts +2 -1
  37. package/dist/cjs/dates/interfaces/IDateSettings.d.ts +5 -0
  38. package/dist/cjs/dates/interfaces/index.d.ts +1 -1
  39. package/dist/cjs/dates/interfaces/index.js +1 -1
  40. package/dist/cjs/format/format.js +6 -0
  41. package/dist/cjs/general/object/applyTimezoneDeep.js +1 -5
  42. package/dist/cjs/qrvey/helpers/transformValue.js +1 -4
  43. package/dist/columns/constants/COLUMN_PROPERTIES.d.ts +1 -1
  44. package/dist/dates/adapters/dateToHms.js +8 -10
  45. package/dist/dates/adapters/dateToMdyDate.d.ts +2 -1
  46. package/dist/dates/adapters/dateToMdyDate.js +9 -3
  47. package/dist/dates/adapters/dateToMonthYear.d.ts +2 -1
  48. package/dist/dates/adapters/dateToMonthYear.js +7 -3
  49. package/dist/dates/adapters/dateToQuarterYear.d.ts +2 -1
  50. package/dist/dates/adapters/dateToQuarterYear.js +8 -4
  51. package/dist/dates/adapters/dateToWeekYear.d.ts +2 -1
  52. package/dist/dates/adapters/dateToWeekYear.js +6 -2
  53. package/dist/dates/adapters/dateToYear.d.ts +2 -1
  54. package/dist/dates/adapters/dateToYear.js +7 -3
  55. package/dist/dates/adapters/hmsToDate.d.ts +2 -1
  56. package/dist/dates/adapters/hmsToDate.js +6 -2
  57. package/dist/dates/adapters/mdyDateToDate.d.ts +2 -1
  58. package/dist/dates/adapters/mdyDateToDate.js +7 -2
  59. package/dist/dates/adapters/monthYearToDate.d.ts +2 -1
  60. package/dist/dates/adapters/monthYearToDate.js +6 -2
  61. package/dist/dates/adapters/quarterYearToDate.d.ts +2 -1
  62. package/dist/dates/adapters/quarterYearToDate.js +6 -2
  63. package/dist/dates/adapters/weekYearToDate.d.ts +2 -1
  64. package/dist/dates/adapters/weekYearToDate.js +10 -6
  65. package/dist/dates/adapters/yearToDate.d.ts +2 -1
  66. package/dist/dates/adapters/yearToDate.js +6 -2
  67. package/dist/dates/helpers/getDateByDateFormat.d.ts +2 -1
  68. package/dist/dates/helpers/getDateByDateFormat.js +6 -6
  69. package/dist/dates/helpers/getDateByTimezone.d.ts +3 -3
  70. package/dist/dates/helpers/getDateByTimezone.js +12 -29
  71. package/dist/dates/helpers/getDateByTimezoneOffset.d.ts +1 -1
  72. package/dist/dates/helpers/getDateByTimezoneOffset.js +10 -2
  73. package/dist/dates/helpers/getDefaultDateSettings.d.ts +7 -0
  74. package/dist/dates/helpers/getDefaultDateSettings.js +13 -0
  75. package/dist/dates/helpers/getFormattedDateByFormat.d.ts +2 -1
  76. package/dist/dates/helpers/getFormattedDateByFormat.js +7 -7
  77. package/dist/dates/helpers/getWeek.js +6 -6
  78. package/dist/dates/interfaces/IDFDateToHmsSettings.d.ts +2 -1
  79. package/dist/dates/interfaces/IDateSettings.d.ts +5 -0
  80. package/dist/dates/interfaces/index.d.ts +1 -1
  81. package/dist/dates/interfaces/index.js +1 -1
  82. package/dist/format/format.js +6 -0
  83. package/dist/general/object/applyTimezoneDeep.js +1 -5
  84. package/dist/qrvey/helpers/transformValue.js +1 -4
  85. package/package.json +1 -1
  86. package/dist/cjs/dates/interfaces/IGetDateByTimezoneSettings.d.ts +0 -6
  87. package/dist/dates/interfaces/IGetDateByTimezoneSettings.d.ts +0 -6
  88. /package/dist/cjs/dates/interfaces/{IGetDateByTimezoneSettings.js → IDateSettings.js} +0 -0
  89. /package/dist/dates/interfaces/{IGetDateByTimezoneSettings.js → IDateSettings.js} +0 -0
@@ -1,6 +1,8 @@
1
1
  import { isEmpty } from "../../general/mix/isEmpty";
2
2
  import { isTokenLabel } from "../../tokens/isTokenLabel";
3
3
  import { DATE_FORMAT } from "../constants/DATE_FORMAT";
4
+ import { getDateByTimezone } from "../helpers/getDateByTimezone";
5
+ import { getDefaultDateSettings } from "../helpers/getDefaultDateSettings";
4
6
  import { getWeek } from "../helpers/getWeek";
5
7
  import { validateDate } from "../helpers/validateDate";
6
8
  /**
@@ -9,20 +11,22 @@ import { validateDate } from "../helpers/validateDate";
9
11
  * @param time Flag to parse the object date to milliseconds.
10
12
  * @returns The date object or the date in milliseconds. If the argument is an unexpected date, the function will return the same value.
11
13
  */
12
- export function weekYearToDate(weekYear, time = false) {
14
+ export function weekYearToDate(weekYear, settings) {
13
15
  if (isEmpty(weekYear) ||
14
16
  isTokenLabel(weekYear) ||
15
17
  typeof weekYear !== "string" ||
16
18
  !validateDate(weekYear, DATE_FORMAT.WEEK))
17
19
  return weekYear;
20
+ const defaultSettings = getDefaultDateSettings(settings);
18
21
  const [week, year] = weekYear.split(" ");
19
22
  const weekNumber = Number(week.substring(1));
20
23
  const dateObj = new Date(+year, 1, 1);
21
- const numOfdaysPastSinceLastSunday = dateObj.getDay();
22
- dateObj.setDate(dateObj.getDate() - numOfdaysPastSinceLastSunday);
24
+ const numOfdaysPastSinceLastSunday = dateObj.getUTCDay();
25
+ dateObj.setDate(dateObj.getUTCDate() - numOfdaysPastSinceLastSunday);
23
26
  const weekNoToday = getWeek(dateObj).week;
24
27
  const weeksInTheFuture = weekNumber - weekNoToday;
25
- dateObj.setDate(dateObj.getDate() + 7 * weeksInTheFuture);
26
- const date = new Date(`${dateObj.getMonth() + 1}/${dateObj.getDate()}/${dateObj.getFullYear()}`);
27
- return time ? +date : date;
28
+ dateObj.setDate(dateObj.getUTCDate() + 7 * weeksInTheFuture);
29
+ const date = new Date(`${dateObj.getUTCMonth() + 1}/${dateObj.getUTCDate()}/${dateObj.getUTCFullYear()}`);
30
+ const timezonedDate = getDateByTimezone(date, defaultSettings.timezone);
31
+ return (defaultSettings === null || defaultSettings === void 0 ? void 0 : defaultSettings.convertMiliseconds) ? +timezonedDate : timezonedDate;
28
32
  }
@@ -1,7 +1,8 @@
1
+ import { IDateSettings } from "../interfaces/IDateSettings";
1
2
  /**
2
3
  * Transforms String Date from a [Year] format to Date object.
3
4
  * @param yearDate String of [Year] date
4
5
  * @param time Flag to parse the object date to milliseconds.
5
6
  * @returns The date object or the date in milliseconds. If the argument is an unexpected date, the function will return the same value.
6
7
  */
7
- export declare function yearToDate(yearDate: string, time?: boolean): string | Date | number;
8
+ export declare function yearToDate(yearDate: string, settings?: IDateSettings): string | Date | number;
@@ -1,6 +1,8 @@
1
1
  import { isEmpty } from "../../general/mix/isEmpty";
2
2
  import { isTokenLabel } from "../../tokens/isTokenLabel";
3
3
  import { DATE_FORMAT } from "../constants/DATE_FORMAT";
4
+ import { getDateByTimezone } from "../helpers/getDateByTimezone";
5
+ import { getDefaultDateSettings } from "../helpers/getDefaultDateSettings";
4
6
  import { validateDate } from "../helpers/validateDate";
5
7
  /**
6
8
  * Transforms String Date from a [Year] format to Date object.
@@ -8,12 +10,14 @@ import { validateDate } from "../helpers/validateDate";
8
10
  * @param time Flag to parse the object date to milliseconds.
9
11
  * @returns The date object or the date in milliseconds. If the argument is an unexpected date, the function will return the same value.
10
12
  */
11
- export function yearToDate(yearDate, time = false) {
13
+ export function yearToDate(yearDate, settings) {
12
14
  if (isEmpty(yearDate) ||
13
15
  isTokenLabel(yearDate) ||
14
16
  typeof yearDate !== "string" ||
15
17
  !validateDate(yearDate, DATE_FORMAT.YEAR))
16
18
  return yearDate;
19
+ const defaultSettings = getDefaultDateSettings(settings);
17
20
  const start = new Date(+yearDate, 0, 1);
18
- return time ? +start : start;
21
+ const timezonedDate = getDateByTimezone(start, defaultSettings.timezone);
22
+ return (defaultSettings === null || defaultSettings === void 0 ? void 0 : defaultSettings.convertMiliseconds) ? +timezonedDate : timezonedDate;
19
23
  }
@@ -1,4 +1,5 @@
1
1
  import { IDateFormat } from "../interfaces/IDateFormat";
2
+ import { IDateSettings } from "../interfaces/IDateSettings";
2
3
  /**
3
4
  * Gets a Date Object instance by a Date format
4
5
  * @param date String with a formatted date
@@ -6,4 +7,4 @@ import { IDateFormat } from "../interfaces/IDateFormat";
6
7
  * @param time flag to convert the formatted date to miliseconds
7
8
  * @returns a Date object, milisecond time or the same value if date format does not match.
8
9
  */
9
- export declare function getDateByDateFormat(date: string, format: IDateFormat, time?: boolean): string | Date | number;
10
+ export declare function getDateByDateFormat(date: string, format: IDateFormat, settings?: IDateSettings): string | Date | number;
@@ -11,21 +11,21 @@ import { mdyDateToDate } from "../adapters/mdyDateToDate";
11
11
  * @param time flag to convert the formatted date to miliseconds
12
12
  * @returns a Date object, milisecond time or the same value if date format does not match.
13
13
  */
14
- export function getDateByDateFormat(date, format, time = false) {
14
+ export function getDateByDateFormat(date, format, settings) {
15
15
  switch (format) {
16
16
  case DATE_FORMAT.YEAR:
17
- return yearToDate(date, time);
17
+ return yearToDate(date, settings);
18
18
  case DATE_FORMAT.MONTH:
19
- return monthYearToDate(date, time);
19
+ return monthYearToDate(date, settings);
20
20
  case DATE_FORMAT.QUARTER:
21
- return quarterYearToDate(date, time);
21
+ return quarterYearToDate(date, settings);
22
22
  case DATE_FORMAT.WEEK:
23
- return weekYearToDate(date, time);
23
+ return weekYearToDate(date, settings);
24
24
  case DATE_FORMAT.DAY:
25
25
  case DATE_FORMAT.HOUR:
26
26
  case DATE_FORMAT.MINUTE:
27
27
  case DATE_FORMAT.SECOND:
28
- return mdyDateToDate(date, time);
28
+ return mdyDateToDate(date, settings);
29
29
  default:
30
30
  return date;
31
31
  }
@@ -1,8 +1,8 @@
1
- import { IGetDateByTimezoneSettings } from "../interfaces/IGetDateByTimezoneSettings";
1
+ import { IDTimezone } from "../interfaces/IDTimezone";
2
2
  /**
3
3
  * Gets a date value in the given timezone
4
4
  * @param {string} date the date
5
- * @param {IGetDateByTimezoneSettings} settings The settings of the getDateByTimezone function
5
+ * @param {IDTimezone} timezone the timezone object
6
6
  * @returns {string} A transformed value
7
7
  */
8
- export declare function getDateByTimezone(date: string, settings: IGetDateByTimezoneSettings): string;
8
+ export declare function getDateByTimezone(date: string | number | Date, timezone: IDTimezone): string | number | Date;
@@ -1,37 +1,20 @@
1
1
  import { isEmpty } from "../../general/mix/isEmpty";
2
- import { DATE_GROUPING_TIME_PROPERTY } from "../constants/DATE_GROUPING_TIME_PROPERTY";
3
- import { TIMEZONE_TYPE } from "../constants/TIMEZONE_TYPE";
4
- import { getDateByDateFormat } from "./getDateByDateFormat";
2
+ import { DATE_FORMAT } from "../constants/DATE_FORMAT";
5
3
  import { getDateByTimezoneOffset } from "./getDateByTimezoneOffset";
6
- import { getDateFormatByProperty } from "./getDateFormatByProperty";
7
- import { getFormattedDateByFormat } from "./getFormattedDateByFormat";
4
+ import { getTimezoneObject } from "./getTimezoneObject";
5
+ import { isValidPotentialDate } from "./isValidPotentialDate";
6
+ import { validateDate } from "./validateDate";
8
7
  /**
9
8
  * Gets a date value in the given timezone
10
9
  * @param {string} date the date
11
- * @param {IGetDateByTimezoneSettings} settings The settings of the getDateByTimezone function
10
+ * @param {IDTimezone} timezone the timezone object
12
11
  * @returns {string} A transformed value
13
12
  */
14
- export function getDateByTimezone(date, settings) {
15
- const defaultSettings = getDefaultSettings(settings);
16
- const isDateTime = [
17
- DATE_GROUPING_TIME_PROPERTY.HOUR,
18
- DATE_GROUPING_TIME_PROPERTY.MINUTE,
19
- DATE_GROUPING_TIME_PROPERTY.SECOND,
20
- ].includes(defaultSettings.property);
21
- if (!isEmpty(defaultSettings.timezone.offset) && isDateTime) {
22
- const dateFormat = getDateFormatByProperty(defaultSettings.property);
23
- const formattedDate = getDateByDateFormat(date, dateFormat);
24
- const timezonedDate = getDateByTimezoneOffset(formattedDate, defaultSettings.timezone.offset);
25
- return getFormattedDateByFormat(timezonedDate, dateFormat);
26
- }
27
- return date;
28
- }
29
- function getDefaultSettings(settings) {
30
- return {
31
- property: settings.property,
32
- timezone: (settings === null || settings === void 0 ? void 0 : settings.timezone) || {
33
- offset: undefined,
34
- type: TIMEZONE_TYPE.DEFAULT,
35
- },
36
- };
13
+ export function getDateByTimezone(date, timezone) {
14
+ const defaultTimezone = getTimezoneObject(timezone);
15
+ if (isEmpty(timezone === null || timezone === void 0 ? void 0 : timezone.offset) ||
16
+ !isValidPotentialDate(date) ||
17
+ (typeof date === "string" && !validateDate(date, DATE_FORMAT.SECOND)))
18
+ return date;
19
+ return getDateByTimezoneOffset(date, defaultTimezone.offset);
37
20
  }
@@ -4,4 +4,4 @@
4
4
  * @param date String, object or millisencond number of the date
5
5
  * @returns updated Date object
6
6
  */
7
- export declare function getDateByTimezoneOffset(date: string | Date | number, offset?: number | string): Date;
7
+ export declare function getDateByTimezoneOffset(date: string | Date | number, offset?: number | string): string | Date | number;
@@ -1,3 +1,4 @@
1
+ import dayjs from "dayjs";
1
2
  import { ISOToNumericOffset } from "../adapters/ISOToNumericOffset";
2
3
  import { DATE_FORMAT } from "../constants/DATE_FORMAT";
3
4
  import { isValidPotentialDate } from "./isValidPotentialDate";
@@ -10,9 +11,16 @@ import { validateDate } from "./validateDate";
10
11
  */
11
12
  export function getDateByTimezoneOffset(date, offset) {
12
13
  if (!isValidPotentialDate(date) ||
13
- (typeof date === "string" && !validateDate(date, DATE_FORMAT.DAY)))
14
+ (typeof date === "string" && !validateDate(date, DATE_FORMAT.SECOND)))
14
15
  return date;
15
16
  const dt = new Date(date.valueOf());
16
17
  const newOffset = ISOToNumericOffset(offset);
17
- return new Date(+dt + newOffset * 1000 * 60);
18
+ const timezonedDate = new Date(+dt + newOffset * 1000 * 60);
19
+ if (typeof date === "string") {
20
+ return dayjs(timezonedDate).format(DATE_FORMAT.SECOND);
21
+ }
22
+ else if (typeof date === "number") {
23
+ return +timezonedDate;
24
+ }
25
+ return timezonedDate;
18
26
  }
@@ -0,0 +1,7 @@
1
+ import { IDateSettings } from "../interfaces/IDateSettings";
2
+ /**
3
+ * Gets the default properties for Date Settings object
4
+ * @param settings the date settings
5
+ * @returns a new object with the date settings.
6
+ */
7
+ export declare function getDefaultDateSettings(settings: IDateSettings): IDateSettings;
@@ -0,0 +1,13 @@
1
+ import { getTimezoneObject } from "./getTimezoneObject";
2
+ /**
3
+ * Gets the default properties for Date Settings object
4
+ * @param settings the date settings
5
+ * @returns a new object with the date settings.
6
+ */
7
+ export function getDefaultDateSettings(settings) {
8
+ var _a;
9
+ return {
10
+ convertMiliseconds: (_a = settings === null || settings === void 0 ? void 0 : settings.convertMiliseconds) !== null && _a !== void 0 ? _a : false,
11
+ timezone: getTimezoneObject(settings === null || settings === void 0 ? void 0 : settings.timezone),
12
+ };
13
+ }
@@ -1,4 +1,5 @@
1
1
  import { IDateFormat } from "../interfaces/IDateFormat";
2
+ import { IDateSettings } from "../interfaces/IDateSettings";
2
3
  /**
3
4
  * A Date object, string or millisecond number are gotten in order to convert it in an formatted string date
4
5
  * - Some strings are valid
@@ -6,4 +7,4 @@ import { IDateFormat } from "../interfaces/IDateFormat";
6
7
  * @param format The date format
7
8
  * @returns a formmatted date or the same value if format does not match
8
9
  */
9
- export declare function getFormattedDateByFormat(date: string | Date | number, format: IDateFormat): string | Date | number;
10
+ export declare function getFormattedDateByFormat(date: string | Date | number, format: IDateFormat, settings?: IDateSettings): string | Date | number;
@@ -11,22 +11,22 @@ import { DATE_FORMAT } from "../constants/DATE_FORMAT";
11
11
  * @param format The date format
12
12
  * @returns a formmatted date or the same value if format does not match
13
13
  */
14
- export function getFormattedDateByFormat(date, format) {
14
+ export function getFormattedDateByFormat(date, format, settings) {
15
15
  switch (format) {
16
16
  case DATE_FORMAT.YEAR:
17
- return dateToYear(date);
17
+ return dateToYear(date, settings);
18
18
  case DATE_FORMAT.MONTH:
19
- return dateToMonthYear(date);
19
+ return dateToMonthYear(date, settings);
20
20
  case DATE_FORMAT.QUARTER:
21
- return dateToQuarterYear(date);
21
+ return dateToQuarterYear(date, settings);
22
22
  case DATE_FORMAT.WEEK:
23
- return dateToWeekYear(date);
23
+ return dateToWeekYear(date, settings);
24
24
  case DATE_FORMAT.DAY:
25
- return dateToMdyDate(date);
25
+ return dateToMdyDate(date, settings);
26
26
  case DATE_FORMAT.HOUR:
27
27
  case DATE_FORMAT.MINUTE:
28
28
  case DATE_FORMAT.SECOND:
29
- return dateToMdyDate(date, true);
29
+ return dateToMdyDate(date, Object.assign(Object.assign({}, settings), { convertMiliseconds: true }));
30
30
  default:
31
31
  return date;
32
32
  }
@@ -9,16 +9,16 @@ export function getWeek(date) {
9
9
  if (!isValidDateObject(date))
10
10
  return;
11
11
  const target = new Date(date.valueOf());
12
- const dayNr = (date.getDay() + 6) % 7;
13
- target.setDate(target.getDate() - dayNr + 3);
12
+ const dayNr = (date.getUTCDay() + 6) % 7;
13
+ target.setDate(target.getUTCDate() - dayNr + 3);
14
14
  const firstThursday = target.valueOf();
15
15
  target.setMonth(0, 1);
16
- if (target.getDay() !== 4) {
17
- target.setMonth(0, 1 + ((4 - target.getDay() + 7) % 7));
16
+ if (target.getUTCDay() !== 4) {
17
+ target.setMonth(0, 1 + ((4 - target.getUTCDay() + 7) % 7));
18
18
  }
19
19
  return {
20
20
  week: 1 + Math.ceil((firstThursday - +target) / 604800000),
21
- month: date.getMonth() + 1,
22
- year: target.getFullYear(),
21
+ month: date.getUTCMonth() + 1,
22
+ year: target.getUTCFullYear(),
23
23
  };
24
24
  }
@@ -1,4 +1,5 @@
1
- export interface IDFDateToHmsSettings {
1
+ import { IDateSettings } from "./IDateSettings";
2
+ export interface IDFDateToHmsSettings extends IDateSettings {
2
3
  omitHour?: boolean;
3
4
  omitMinute?: boolean;
4
5
  omitSecond?: boolean;
@@ -0,0 +1,5 @@
1
+ import { IDTimezone } from "./IDTimezone";
2
+ export interface IDateSettings {
3
+ timezone?: IDTimezone;
4
+ convertMiliseconds?: boolean;
5
+ }
@@ -2,8 +2,8 @@ export * from "./IBTimezone";
2
2
  export * from "./IBTimezoneType";
3
3
  export * from "./IDateFormat";
4
4
  export * from "./IDateGroupingProperty";
5
+ export * from "./IDateSettings";
5
6
  export * from "./IDFDateToHmsSettings";
6
7
  export * from "./IDTimezone";
7
8
  export * from "./IDTimezoneOffset";
8
9
  export * from "./IDTimezoneType";
9
- export * from "./IGetDateByTimezoneSettings";
@@ -2,8 +2,8 @@ export * from "./IBTimezone";
2
2
  export * from "./IBTimezoneType";
3
3
  export * from "./IDateFormat";
4
4
  export * from "./IDateGroupingProperty";
5
+ export * from "./IDateSettings";
5
6
  export * from "./IDFDateToHmsSettings";
6
7
  export * from "./IDTimezone";
7
8
  export * from "./IDTimezoneOffset";
8
9
  export * from "./IDTimezoneType";
9
- export * from "./IGetDateByTimezoneSettings";
@@ -1,9 +1,13 @@
1
1
  import { format as d3Format } from "d3-format";
2
2
  import dayjs from "dayjs";
3
3
  import { DATEGROUP_FORMATTING_UNSUPPORT, appliesFormatting, hasfileSizeProperty, isTextColumn, DEFAULT_DATE, } from "./definition";
4
+ //* *dayjs plugins */
4
5
  import isoWeek from "dayjs/plugin/isoWeek";
5
6
  import advancedFormat from "dayjs/plugin/advancedFormat";
6
7
  import utc from "dayjs/plugin/utc";
8
+ import weekYear from "dayjs/plugin/weekYear";
9
+ import weekOfYear from "dayjs/plugin/weekOfYear";
10
+ //* * end dayjs plugin imports */
7
11
  import { isEmpty } from "../general/mix/isEmpty";
8
12
  import { _get } from "../general/object/get";
9
13
  import { COLUMN } from "../columns/constants/COLUMN";
@@ -15,6 +19,8 @@ import { cloneDeep } from "../general/object/cloneDeep";
15
19
  dayjs.extend(isoWeek); // Add support for iso week format https://github.com/iamkun/dayjs/issues/1328
16
20
  dayjs.extend(advancedFormat); // Add support to advanced formats https://day.js.org/docs/en/plugin/advanced-format
17
21
  dayjs.extend(utc);
22
+ dayjs.extend(weekYear);
23
+ dayjs.extend(weekOfYear);
18
24
  /**
19
25
  * Apply to the given date format to a date value
20
26
  * @param bytes type number
@@ -1,5 +1,4 @@
1
1
  import { DATE_FORMAT } from "../../dates/constants/DATE_FORMAT";
2
- import { DATE_GROUPING_TIME_PROPERTY } from "../../dates/constants/DATE_GROUPING_TIME_PROPERTY";
3
2
  import { getDateByTimezone } from "../../dates/helpers/getDateByTimezone";
4
3
  import { validateDate } from "../../dates/helpers/validateDate";
5
4
  import { isEmpty } from "../mix/isEmpty";
@@ -27,10 +26,7 @@ export function applyTimezoneDeep(obj, timezone) {
27
26
  }
28
27
  else if (obj[i] instanceof Date ||
29
28
  validateDate(obj[i], DATE_FORMAT.HOUR)) {
30
- result[i] = getDateByTimezone(obj[i], {
31
- property: DATE_GROUPING_TIME_PROPERTY.HOUR,
32
- timezone,
33
- });
29
+ result[i] = getDateByTimezone(obj[i], timezone);
34
30
  }
35
31
  else {
36
32
  result[i] = obj[i];
@@ -20,10 +20,7 @@ export function transformValue(value, settings) {
20
20
  const defaultSettings = getDefaultSettings(settings);
21
21
  let timezonedValue = value;
22
22
  if (!defaultSettings.noTimezone) {
23
- timezonedValue = getDateByTimezone(value, {
24
- property: defaultSettings.property,
25
- timezone: defaultSettings.timezone,
26
- });
23
+ timezonedValue = getDateByTimezone(value, defaultSettings.timezone);
27
24
  }
28
25
  let valueWithI18n = timezonedValue;
29
26
  if (!defaultSettings.noTranslate) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@qrvey/utils",
3
- "version": "1.10.0-7",
3
+ "version": "1.10.0-9",
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",
@@ -1,6 +0,0 @@
1
- import { IColumnPropertyType } from "../../columns/interfaces/IColumnPropertyType";
2
- import { IDTimezone } from "./IDTimezone";
3
- export interface IGetDateByTimezoneSettings {
4
- property: IColumnPropertyType;
5
- timezone: IDTimezone;
6
- }
@@ -1,6 +0,0 @@
1
- import { IColumnPropertyType } from "../../columns/interfaces/IColumnPropertyType";
2
- import { IDTimezone } from "./IDTimezone";
3
- export interface IGetDateByTimezoneSettings {
4
- property: IColumnPropertyType;
5
- timezone: IDTimezone;
6
- }