@salesforcedevs/dx-components 1.3.25 → 1.3.26

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@salesforcedevs/dx-components",
3
- "version": "1.3.25",
3
+ "version": "1.3.26",
4
4
  "description": "DX Lightning web components",
5
5
  "license": "MIT",
6
6
  "engines": {
@@ -38,5 +38,5 @@
38
38
  "eventsourcemock": "^2.0.0",
39
39
  "luxon": "^3.1.0"
40
40
  },
41
- "gitHead": "47eb24c8ff76bf71e4b8eff4e2f9ced63a4d340f"
41
+ "gitHead": "31be8a973c75cec3678c6ec7308fb6099b29d055"
42
42
  }
@@ -1,4 +1,5 @@
1
1
  import { LightningElement, api } from "lwc";
2
+ import { convertForDaylightSavings } from "dxUtils/dates";
2
3
  import {
3
4
  formattedDateDay,
4
5
  formattedDateHour,
@@ -11,8 +12,6 @@ import {
11
12
  formattedDateYear
12
13
  } from "typings/custom";
13
14
 
14
- import { DateTime } from "luxon";
15
-
16
15
  export default class FormattedDateTime extends LightningElement {
17
16
  @api weekday: formattedDateWeekday;
18
17
  @api year: formattedDateYear;
@@ -29,11 +28,7 @@ export default class FormattedDateTime extends LightningElement {
29
28
  return;
30
29
  }
31
30
 
32
- this._unformattedDate = DateTime.fromISO(value)
33
- .plus({
34
- hour: 1
35
- })
36
- .toJSDate();
31
+ this._unformattedDate = convertForDaylightSavings(value).toJSDate();
37
32
 
38
33
  if (this._unformattedDate.toString() === "Invalid Date") {
39
34
  // this is a fix for Safari since it doesn't support date strings with 'yyyy/mm/dd' patterns
@@ -1,3 +1,5 @@
1
+ import { DateTime } from "luxon";
2
+
1
3
  const MONTHS = {
2
4
  January: 0,
3
5
  February: 1,
@@ -20,7 +22,6 @@ const MONTHS = {
20
22
  "January 2022": [ *array of dates for this month* ],
21
23
  }
22
24
  */
23
-
24
25
  export function sortSplittedPostsByMonth(postsByMonth: any) {
25
26
  const sortedPostsByMonth: { [key: string]: Array<{}> } = {};
26
27
 
@@ -58,3 +59,23 @@ export function sortSplittedPostsByMonth(postsByMonth: any) {
58
59
 
59
60
  return sortedPostsByMonth;
60
61
  }
62
+
63
+ export function convertForDaylightSavings(
64
+ date: string,
65
+ zone: string = "local"
66
+ ) {
67
+ if (!hasDST(zone)) {
68
+ return DateTime.fromISO(date).setZone(zone);
69
+ }
70
+
71
+ return DateTime.fromISO(date).setZone(zone).isInDST
72
+ ? DateTime.fromISO(date).setZone(zone)
73
+ : DateTime.fromISO(date).setZone(zone).plus({ hour: 1 });
74
+ }
75
+
76
+ export function hasDST(zone: string = "local") {
77
+ return (
78
+ DateTime.fromISO("2022-01-01").setZone(zone).isInDST !==
79
+ DateTime.fromISO("2022-06-01").setZone(zone).isInDST
80
+ );
81
+ }